<?php
    //php屏蔽手机号和固话的中间四位
    //php屏蔽手机号码的中间四位
    //方法1 利用正则
    $phone = 13811119999;
    echo preg_replace('/(1[3|4|5|6|7|8|9][0-9])[0-9]{4}([0-9]{4})/i','$1****$2',$phone);
    echo "<br>";
    //方法2
    echo substr_replace($phone,'****',3,4);
    echo "<br>";

    //ps屏蔽固话中间四位
    $tel1 = "0632-2396517";
    $tel2 = "0632-2396517-083";
    echo preg_replace('/(0[0-9]{2,3}[\-]?[2-9])[0-9]{3,4}([0-9]{3}[\-]?[0-9]?)/i','$1****$2',$tel1);
    echo "<br>";
    echo preg_replace('/(0[0-9]{2,3}[\-]?[2-9])[0-9]{3,4}([0-9]{3}[\-]?[0-9]?)/i','$1****$2',$tel2);

?>