PHP 手机号中间4位加密


    /**
     * 中间加密 字符串截取法
     */
    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;
    }

很实用。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM