Created
March 10, 2019 12:26
-
-
Save ayatmaulana/053d3093837d4f0b06b5263109258c2c to your computer and use it in GitHub Desktop.
check indonesia provider by phone number
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
<?php | |
$providerList = [ | |
"telkomsel" => [ | |
"0811", | |
"0812", | |
"0813", | |
"0821", | |
"0822", | |
"0823", | |
"0852", | |
"0853", | |
"0851" | |
], | |
"indosat" => [ | |
"0814", | |
"0815", | |
"0816", | |
"0855", | |
"0856", | |
"0857", | |
"0858", | |
], | |
"xl" => [ | |
"0817", | |
"0818", | |
"0819", | |
"0859", | |
"0877", | |
"0878", | |
], | |
"three" => [ | |
"0895", | |
"0896", | |
"0897", | |
"0898", | |
"0899", | |
], | |
"axis" => [ | |
"0838", | |
"0831", | |
"0832", | |
"0833", | |
] | |
]; | |
$myNumber = "08336727337"; | |
$result = null; | |
foreach ($providerList as $key => $value) { | |
foreach ($value as $key2 => $value2) { | |
if (preg_match("/^{$value2}.*/", $myNumber)) | |
{ | |
$result = $key; | |
break; | |
} | |
} | |
} | |
echo $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment