Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Created February 19, 2016 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d1i1m1o1n/af13ddce62588a836d29 to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/af13ddce62588a836d29 to your computer and use it in GitHub Desktop.
Is phone function
<?php
function isPhone($val){
if (!preg_match('/^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/iu', $val))
return false;
return true;
}
//allow
/*
+79261234567
89261234567
79261234567
+7 926 123 45 67
8(926)123-45-67
123-45-67
9261234567
79261234567
(495)1234567
(495) 123 45 67
89261234567
8-926-123-45-67
8 927 1234 234
8 927 12 12 888
8 927 12 555 12
8 927 123 8 123
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment