Skip to content

Instantly share code, notes, and snippets.

@ayatmaulana
Created March 10, 2019 12:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayatmaulana/053d3093837d4f0b06b5263109258c2c to your computer and use it in GitHub Desktop.
Save ayatmaulana/053d3093837d4f0b06b5263109258c2c to your computer and use it in GitHub Desktop.
check indonesia provider by phone number
<?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