The simplest of the most practical PHP mobile phone number Regular expression, there is a need for friends to refer to.
Mobile: 134, 135, 136, 137, 138, 139, 150, 151, 157 (TD), 158, 159, 187, 188
Unicom: 130, 131, 132, 152, 155, 156, 185, 186
Telecom: 133, 153, 180, 189, (1349 Wei Tong)
Mobile phone number rules
| The code is as follows |
Copy Code |
$regex = "/13[0-9]{9}|15[0|1|2|3|5|6|7|8| 9]d{8}|18[0|5|6|7|8| 9]d{8}/"; |
Example 1
Determine the phone number:
| The code is as follows |
Copy Code |
function Is_mobile ($STR) { Return Preg_match ("/^ ((D{3}) | ( d{3}-)) 13d{9}$/", $str); } |
Instance
| The code is as follows |
Copy Code |
function Checkmobile ($STR) { $pattern = "/^ (13|15) d{9}$/"; if (Preg_match ($pattern, $STR)) { Return true; } Else { Return false; } } Calling functions $str = Checkmobile ("15800000001″"); if ($STR) { Echo ("Compliant with mobile phone number standard"); } Else { Echo ("Does not conform to mobile phone number standard"); } ?>
|
Finally, you can fully verify the current phone number code
| The code is as follows |
Copy Code |
Preg_match_all ($regex, $row [' Mobile '], $phones); if ($phones) { That's right } |
Friendship tips, now about cell phone judgment, is really not very good to do, because the mobile phone number changes have been relatively large. Maybe today you write a regular, tomorrow will be a new number segment, make a cell phone number segment array, determine whether in the number segment array =array (130,131,132 ...) In_array (substr (number, 0, 3), array)
http://www.bkjia.com/PHPjc/628966.html www.bkjia.com true http://www.bkjia.com/PHPjc/628966.html techarticle The simplest of the most practical PHP mobile phone number Regular expression, there is a need for friends to refer to. Mobile: 134, 135, 136, 137, 138, 139, 150, 151, 157 (TD), 158, 159, 187 , ...