/**
 * 对手机号进行掩码处理
 * 手机号掩码的规则是末尾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));
    }
}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部