Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Валидация мобильного телефонного номера
<?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