PHP 手机号中间4位加密

180it 2021-10-03 PM 1511℃ 0条

/**

  • 中间加密 字符串截取法
    */

public static function encryptTel($tel) {

$new_tel = substr($tel, 0, 3).'****'.substr($tel, 7);        return $new_tel;

} /**

  • 中间加密 替换字符串的子串
    */

public static function encryptTel($tel) {

$new_tel = substr_replace($tel, '****', 3, 4);        return $new_tel;

} /**

  • 中间加密 用正则
    */

public static function encryptTel($tel) {

$new_tel = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $tel);        return $new_tel;

}

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

PHP 手机号中间4位加密