Created
September 15, 2018 11:16
-
-
Save iamshanto/a0b69c51ff63b4d2b58618249f384e7f to your computer and use it in GitHub Desktop.
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 sanitizeMobileNumber($mobile, $prefix = '0') | |
{ | |
$mobile = ltrim(trim($mobile), '.+80'); | |
$mobile = str_replace([' ', '-', '.', '+'], '', $mobile); | |
$mobile = strrev(substr(strrev($mobile), 0, 10)); | |
if (!in_array(substr($mobile, 0, 2), ['15', '16', '17', '18', '19', '13']) || strlen($mobile) != 10) { | |
return null; | |
} | |
return $prefix.$mobile; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment