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