Last active
October 30, 2017 10:52
-
-
Save nawawi/8fc646a927d043737a4b to your computer and use it in GitHub Desktop.
check valid phone number format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _check_phone_number($string, &$data = null ) { | |
if ( preg_match( '/^[+]?([\d]{0,3})?[\(\.\-\s]?([\d]{3})[\)\.\-\s]*([\d]{3})[\.\-\s]?([\d]{4})$/', $string, $mm ) ) { | |
$data = $mm; | |
return true; | |
} | |
// 13102016: malaysia format 00-000 000 00-000000 | |
if ( preg_match( '/^[+]?([\d]{0,2})?[\(\.\-\s]?([\d]{2})[\)\.\-\s]*([\d]{2})[\.\-\s]?([\d]{4})$/', $string, $mm ) ) { | |
$data = $mm; | |
return true; | |
} | |
if ( _num($string) && strlen($string) >= 7 ) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment