Filter telephone numbers per country code / first digits
Posted: Sat Jan 28, 2012 10:41 am
Hello,
I am setting up a Click2Call app for my new website. I am trying to keep only numbers that start with specific digits (defined in an array) so that I don't end up being pranked and calling premium numbers in Asia or anywhere else.
Here is my regex:
And here's the code that generates it:
$_GET['num'] was set to +447xxx (xxx where actual digits), then +447, with no match.
This is not my final code obviously, only the first step to test my regex against sample numbers. The whole thing doesn't seem to working so far (result is "0") and a bit of help would be appreciated.
Thank you in advance
G.
I am setting up a Click2Call app for my new website. I am trying to keep only numbers that start with specific digits (defined in an array) so that I don't end up being pranked and calling premium numbers in Asia or anywhere else.
Here is my regex:
Code: Select all
/^(\+441|\+442|\+447|\+4430|\+4433|\+44500|\+4480|\+336|\+331|\+332|\+333|\+334|\+335|\+33800|\+339)/iCode: Select all
$authorized_numbers = array("+441","+442","+447","+4430","+4433","+44500","+4480","+336","+331","+332","+333","+334","+335","+33800","+339");
$c2cregexp = "/^(" . str_replace("+","\+",implode ( '|', $authorized_numbers )). ")/i";
print_r(preg_match ($c2cregexp , $_GET['num'] ), $other)This is not my final code obviously, only the first step to test my regex against sample numbers. The whole thing doesn't seem to working so far (result is "0") and a bit of help would be appreciated.
Thank you in advance
G.