/**
* 对手机号进行掩码处理
* 手机号掩码的规则是末尾4位,开头余数位不变,中间4的整数倍字符用星号替换
* @author 萤火虫<123246359@qq.com>
* @param string $mobile 手机号
* @return string
*/
if (!function_exists('formatMobile')) {
function formatMobile($mobile){
//颠倒顺序每隔4位分割为数组
$split = str_split(strrev($mobile),4);
//头和尾保留,其他部分替换为星号
$split = array_fill(1,count($split) - 2,"****") + $split;
ksort($split);
//合并颠倒顺序
return strrev( implode("",$split));
}
}
发表评论 取消回复