Php mobile phone number verification judgment function (segments 170 and 180)

Source: Internet
Author: User
The simplest and most practical regular expression for php mobile phone numbers. For more information, see. mobile: 134, 135, 136, 137, 138, 139, 150, 151, 157 (TD), 158, 159, 187, 188 Unicom: 130... the simplest and most practical regular expression for php mobile phone numbers. For more information, see.

Mobile: 134, 135, 136, 137, 138, 139, 150, 151, 157 (TD), 158, 159, 187, 188

China Unicom: 130, 131, 132, 152, 155, 156, 185, 186

China Telecom: 133, 153, 180, 189 (1349 Weitong)

The instance code of the mobile phone number rule is as follows:

$regex = "/13[0-9]{9}|15[0|1|2|3|5|6|7|8|9]\d{8}|17[0|1|2|3|5|6|7|8|9]\d{8}|18[0|5|6|7|8|9]\d{8}/";

The code used to determine the mobile phone number is as follows:

function is_mobile($str){     return preg_match("/^(((\d{3}))|(\d{3}-))?13\d{9}$/", $str); }

The instance code is as follows:

 

Finally, all mobile phone numbers can be verified.

The instance code is as follows:

Preg_match_all ($ regex, $ row ['mobile'], $ phones); if ($ phones) {correct}

Friendly reminder: it is really difficult to judge the mobile phone number, because the mobile phone number has changed a lot. maybe you have written a regular expression today, and a new number segment will be generated tomorrow. make a cell phone number segment array and determine whether the array is in the number segment = array (130,131,132 .....) in_array (substr (number, 0, 3), array)


Tip: Add CIDR block 180 and CIDR block 170.

Address:

Reprinted at will, but please attach the article address :-)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.