Writing validation for e.164
Date: 03/27/05
(PHP Community) Keywords: no keywords
I've been looking at e.164 of later for validation for the SMS::Clickatell stuff I wrote some time ago and I'm looking at adding basic validation for mobile numbers to the SMS validation module which I'm working on.
I was thinking about using a preg_match which can extract the number for the country prefix and check that the country prefix does not exist on a list of unassigned list. Then work out network prefixes, etc. etc.
The regex is most likely going to look ugly, considering that I started using a switch on the first number i.e.
function validatenumber($number) {
switch ($number[0]) {
case '1':
/**
* NADP (North American Dialling Plan
*/
$prefix = "1";
break;
...
}
return ($prefix);
}
?>
Source: http://www.livejournal.com/community/php/277646.html