Hi guys,
I have just recently started to use php so kindda new kid on the block. My site will signup user using their mobile phone. Hence, when user enter their mobile phone number like 44123456789 or 353123456789123, where the first 2 digits (44) and first 3 digit (353) is the country dialling code. So how am I able to verify using php script if this 1st 2 or 3 digits is a valid country dialling code by given a list of like 250 valid country code?
Appreciate any help here please.
Thanks and reagrds,
Mark
Checking country dialling code
Moderator: General Moderators
Re: Checking country dialling code
Code: Select all
$number = "4412345674"; // get this from your user
$valid_codes = array("44", "34", "56", "67"); // List of valid codes
$code = substr($number, 0, 2); // get the first 2 digits
if(in_array($code, $valid_codes)) // check the array
echo "VALID";
else
echo "INVALID";