Fork me on github

php隐藏手机号指定位数


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

posted @ 2018-09-14 17:14  Champion-水龙果  阅读(258)  评论(0编辑  收藏  举报
Champion-水龙果