function valid_eg_phone_number in Phone 6
Same name and namespace in other branches
- 7 include/phone.eg.inc \valid_eg_phone_number()
File
- ./
phone.eg.inc, line 77
Code
function valid_eg_phone_number($phonenumber) {
/*
accepts:
properly formatted: [+20][ ][(]#[#][)][ ]1234[ ]567[#]
common: [(][0#[#]][)][ ]123[ ]456[#]
area code could be within paranthises and|or prefixed with 0
*/
$regex = "/^\t\t\t\t\t\t# the same as the model regex above, but with elements made optional\n\t\t(\\+20)?\\s?\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# country code, with following space being optional\n (\n\t\t\t\t(\\(0?2\\)|0?2)\\s?(2|3)\\d{3}\\s?\\d{4}\t\t\t\t# Greater Cairo, with leading optional zeros and optional braces around the area code\n\t\t\t|\n\t\t\t\t(\\(0?" . AREA_CODE_REGEX . "\\)|0?" . AREA_CODE_REGEX . ")\\s?\\d{3}\\s?\\d{4}\t\t\t\t\t# other areas, with optional leading zeros and braces\n\t\t\t|\n\t\t\t\t(\\(0?" . MOBILE_CODE_REGEX . "\\)|0?" . MOBILE_CODE_REGEX . ")\\s?\\d{3}\\s?\\d{4}\t\t# mobiles, with optional leading zeros and braces\n\t\t)\n\t\t(\\s?\\#\\s?\\d+)? \t\t\t\t\t\t\t\t\t# extension\n\t\$/x";
return (bool) preg_match($regex, $phonenumber);
}