Created
March 4, 2020 08:28
-
-
Save AlifArnado/3893d5d77da35fc99e18f339aec55391 to your computer and use it in GitHub Desktop.
fungsi untuk mengubah nomor telepon yang di depan ada terjadi inputan +62 dan 62 untuk di ubah menjadi 08 atau menghapus angka +62 atau 62 kode area indonesia menjadi 08 normal nomor telepon
This file contains hidden or 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
function regex_no_hp_62_0($nohp) { | |
$no = ""; | |
if (preg_match('/^(?:\+62)/',trim($nohp))) { | |
// echo "ada tanda +62 <br>"; | |
$no = substr_replace($nohp,'0',0,3); | |
} else if (preg_match('/^(?:62)/',trim($nohp))) { | |
// echo "ada tanda 62 <br>"; | |
$no = substr_replace($nohp,'0',0,2); | |
} else { | |
// echo "number yg di cari 08 <br>"; | |
$no = $nohp; | |
} | |
return $no; | |
} | |
$nohp = "+628562121141"; | |
print_r(regex_no_hp_62_0($nohp)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment