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 phonenumber($value) | |
{ | |
$areacode = '[2-9]{1}\d{1}\d{1}'; // You might want to specify '2\d\d' (200 to 299) | |
$prefix = '[2-9]{1}\d{1}\d{1}'; | |
$regex = '#^(\('.$areacode.'\)|'.$areacode.')[\s\.-]?'.$prefix.'[\.-]?\d{4}$#'; | |
if (preg_match($regex, $value)) | |
{ | |
// Number now is in a suitable format | |
// extract digits -- remove this section to not test repeated pattern |