//方法1-正则标签:手机号,星号,pattern,preg,resstr,echo,substr,str,替换 From: https://www.cnblogs.com/jinjindandan/p/17393855.html
$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;