PHP隐藏手机号码中间几位
!!!又一年程序猿(媛)节日到了,想着给自己放个假,最后还是挣扎起床上班咯(还不是因为穷~~~~~)搬砖搬砖搬砖,,,,,今天忽然想起来最近做的隐藏手机中间位的功能,写一哈仅供参考哦!!!
preg_match('/([0-9a-z]{3})[0-9a-z]+([0-9a-z]{2})(.*)/i', $phone, $matche);
//如果有国外的手机号需要判断一下哦(展示区号操作)
$phoneArr = explode('-', $phone);
if (count($phoneArr) == 2 && $phoneArr[0] != 86) {
$matche[1]= $phoneArr[0].'-'.$matche[1];
}
return $matche[1] . '****' . $matche[2] . $matche[3];
如果遇到更好的方法欢迎留言啊