手机号替换为星号
//方法1-正则
$str = '15864236586';
$pattern = '/(\d{2})(\d{7})(\d{2})/i';
$a = preg_match($pattern,$str);
$replacement = '$1*******$3';
$resstr = preg_replace($pattern, $replacement,$str);
echo $resstr;
//方法2-字符串截取
$str = '15864236586';
$new_str = substr($str,0,2).'*******'.substr($str,-2);
echo $new_str;