久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網
      最全最豐富的資訊網站

      實用講解PHP隱藏手機號碼中間4位方法

      推薦:《PHP視頻教程》

      今天突然想起手機號,這種隱私信息在項目中還是隱藏一下比較好,所以就來總結一下能用的方法,僅限于大陸的11位手機號

      方法演示

      1.使用 substr_replace函數

      # substr_replace — 替換字符串的子串 # 使用說明 substr_replace ( mixed $string , mixed $replacement , mixed $start , mixed $length = ? ) : mixed # $string 資源字符串 # $replacement 替換字符 # $start 替換開始位置,如果位負數的時候,將從末尾開始數 # $length 需要替換的長度,如果為負數的時候,也是從$start開始位置替換 # substr_replace() 在字符串 string 的副本中將由 start 和可選的 length 參數限定的子字符串使用 replacement 進行替換。 # 示例 $mobile = '18512341234'; echo substr_replace($mobile, '****', 3, 4);         // 185****1234 # 注意 字符串的開始位置為0 echo substr_replace($mobile, '****', -8, -4);    // 185****1234

      2.使用正則表達式

      # preg_replace — 執(zhí)行一個正則表達式的搜索和替換 # 使用說明 preg_replace ( mixed $pattern , mixed $replacement , mixed $subject , int $limit = -1 , int &$count = ? ) : mixed # 搜索 subject 中匹配 pattern 的部分,以 replacement 進行替換。  # 示例 $pattern = '/(d{3})d{4}(d{4})/'; $new_mobile = preg_replace($pattern, '$1****$2', $mobile); echo $new_mobile;

      3.使用 substr函數

      # 函數說明 substr ( string $string , int $start , int $length = ? ) : string # 返回字符串 string 由 start 和 length 參數指定的子字符串。    # 同 substr_replace 一樣,start也可以為負數的 # 示例 echo substr($mobile, 0,3) . '****' . substr($mobile, 7,4); echo substr($mobile, 0,3) . '****' . substr($mobile, -4,4);

      總結

      方法有很多,多數情況是在情況選擇那種更加合適.

      贊(0)
      分享到: 更多 (0)
      網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號