php座机正则,php电话正则

function isTel($tel,$type='')

{

$regxArr = array(

'sj' => '/^(\+?86-?)?(18|15|13)[0-9]{9}$/',

'tel' => '/^(010|02\d{1}|0[3-9]\d{2})-\d{7,9}(-\d+)?$/',

'400' => '/^400(-\d{3,4}){2}$/',

);

if($type && isset($regxArr[$type]))

{

return preg_match($regxArr[$type], $tel) ? true:false;

}

foreach($regxArr as $regx)

{

if(preg_match($regx, $tel ))

{

return true;

}

}

return false;

}

$tm1 = microtime(true);

$arr = array(

'15910241024',

'+861591900 0000',

'86159 1930 9100',

'+86-15312001200',

'18655321002',

'02089571800',

'020-89571800',

'0755-102410240',

'0553-10241024',

'010-1204120140',

'010-120412014',

'110-89571800',

'022-102410240',

'0222-102410241',

'400-020-9800',

'400-0588-010',

'400-0211-0112',

);

foreach ($arr as $tel)

{

echo "\n{$tel}:\t".(isTel($tel) ? "是":"错误");

}

echo sprintf("\n\ntaken %.6f s",microtime(true)-$tm1);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值