PHP实现手机号码中间四位用星号(*)隐藏的自定义函数分享
PHP实现手机号码中间四位用星号(*)隐藏的自定义函数分享手机和座机:<?php
function hidtel($phone){
$IsWhat = preg_match('/(0{2,3}[-]?{6,7}[-]??)/i',$phone); //固定电话
if($IsWhat == 1){
return preg_replace('/(0{2,3}[-]?){3,4}({3}[-]??)/i','$1****$2',$phone);
}else{
returnpreg_replace('/(1{1}){4}({4})/i','$1****$2',$phone);
}
}
$phonenum = "010-88888888";
echo hidtel($phonenum);
?>
手机号码:<?php
$num = "13888888888"
$str = substr_replace($num,'****',3,4);
?>
页:
[1]