+
95
-

php如何根据手机号判断运营商?

php

php如何根据手机号判断运营商?


网友回复

+
15
-

可用正则匹配号段实现,php代码如下:

<?php

function getOperatorByPhoneNumber( $phoneNumber)
{
    // 中国移动正则表达式
    $cmccPattern = '/^1(3[4-9]|4[7]|5[0-27-9]|7[28]|8[2-478]|9[8])\d{8}$/';

    // 中国联通正则表达式
    $cuccPattern = '/^1(3[0-2]|4[5]|5[56]|6[67]|7[56]|8[56]|9[6])\d{8}$/';

    // 中国电信正则表达式
    $c...

点击查看剩余70%

我知道答案,我要回答