Last active
December 15, 2016 06:22
-
-
Save codingfox-rus/15a2edcb85354a713e73 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
<?php | |
/** | |
* @param $phone | |
* @return bool | |
*/ | |
public function correctPhone($phone) | |
{ | |
$phone = preg_replace('/[^0-9]/', '', trim($phone)); | |
preg_match('/9[0-9]{9,9}/', $phone, $result); | |
if ( !empty($result) ) { | |
return '7' . $result[0]; | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment