/** * 中间加密 字符串截取法 */ function encryptTel1($tel1) { $new_tel = substr($tel, 0, 3).'****'.substr($tel, 7); return $new_tel; } /** * 中间加密 替换字符串的子串 */ function encryptTel2($tel2) { $new_tel = substr_replace($tel, '****', 3, 4); return $new_tel; }
/** * 中间加密 用正则 */ function encryptTel3($tel3) { $new_tel = preg_replace('/(\d{3})d{4}(d{4})/', '****', $tel); return $new_tel; } echo encryptTel3(15039378786);
js手机号加密
let val = 15039378786; let phone = String(val); let reg = /(\d{3})\d{4}(\d{4})/; console.log(phone.replace(reg, '$1****$2')) ;
标签:function,tel,手机号,replace,substr,new,加密 From: https://www.cnblogs.com/junwuxiao/p/17082621.html