/**
* 必须带有数字 全英文无法替换
* @param $phone
* @return mixed|string
*/
public static function phoneReplaceUtil($phone){
$_phone = '';
if ($phone) {
preg_match_all('/\d/',$phone,$matches);
$_phone = str_replace(',','',implode(',',$matches[0]));
if ($_phone) {
if (preg_match_all('/((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9])|(17[0-9]))\d{8}$/',$_phone) ) {
preg_match_all('/^0\d{2}/',$_phone,$m);
$prefix = str_replace(',','',implode(',',$m[0]));
$_phone = str_replace($prefix,'',$_phone);
$_phone = str_replace(substr($_phone,3,4),'****',$_phone);
}elseif (preg_match_all('/^0\d{2,3}|[2-9]\d{6,7}$/',$_phone)){
if (preg_match_all('/^0\d{2,3}/',$_phone) && strlen($_phone) <= 12) {
$_phone = str_replace(substr($_phone,-4,4),'****',$_phone);
}elseif(strlen($_phone) > 12){
$_phone = str_replace(substr($_phone,-8,6),'********',$_phone);
}else{
$_phone = str_replace(substr($_phone,-3,4),'****',$_phone);
}
}else{
if (strlen($_phone) > 2) {
$_phone = str_replace(substr($_phone,-2),'**',$_phone);
}
}
}
}
return $_phone;
}