Skip to content

Instantly share code, notes, and snippets.

@pamjadz
Last active November 5, 2022 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamjadz/ab7798a84f099b2f5a706332c2037a03 to your computer and use it in GitHub Desktop.
Save pamjadz/ab7798a84f099b2f5a706332c2037a03 to your computer and use it in GitHub Desktop.
اعتبارسنجی شماره تلفن همراه ایران
function sanitize_irphone($number){
$newNumbers = range(0, 9);
$char_arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
$number = str_replace($char_arabic, $newNumbers, $number);
$char_persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$number = str_replace($char_persian, $newNumbers, $number);
$number = '0'.preg_replace('/^(?:98|\+98|0098|0)?9/i', '9', $number);
return $number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment