php隐藏手机号指定位数php
function mobileReplace($mobile,$start,$end,$str="*"){
$countStr = abs($end-$start);
$replaceStr = $str;
for($i=0;$i<$countStr;$i++){
&nbs...
function mobileReplace($mobile,$start,$end,$str="*"){
$countStr = abs($end-$start);
$replaceStr = $str;
for($i=0;$i<$countStr;$i++){
$replaceStr.= $str;
}
$mobile = substr_replace($mobile, $replaceStr, $start-1, $countStr+1);
return $mobile;;
}
$mobile = '13188888888';
echo mobileReplace($mobile,4,7); //132****8888
$countStr = abs($end-$start);
$replaceStr = $str;
for($i=0;$i<$countStr;$i++){
$replaceStr.= $str;
}
$mobile = substr_replace($mobile, $replaceStr, $start-1, $countStr+1);
return $mobile;;
}
$mobile = '13188888888';
echo mobileReplace($mobile,4,7); //132****8888
下一篇:好用的PHP分页类
最新评论
热门推荐
我要评论