久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php如何去除html,空格,換行,提取純文字

      php去除html,空格,換行,提取純文字的方法:1、清除字符串兩邊的空格,代碼為【$str = trim($str)】;2、匹配html中的空格,代碼為【$str = preg_replace("/ /","",$str)】。

      php如何去除html,空格,換行,提取純文字

      php去除html,空格,換行,提取純文字的方法:

      方法一:

      function DeleteHtml($str)  {      $str = trim($str); //清除字符串兩邊的空格     $str = preg_replace("/t/","",$str); //使用正則表達式替換內(nèi)容,如:空格,換行,并將替換為空。     $str = preg_replace("/rn/","",$str);      $str = preg_replace("/r/","",$str);      $str = preg_replace("/n/","",$str);      $str = preg_replace("/ /","",$str);     $str = preg_replace("/  /","",$str);  //匹配html中的空格     return trim($str); //返回字符串 }

      調(diào)用方法

      DeleteHtml($str);

      $str 為需要清除的頁面字符串

      方法二:

      function DeleteHtml($str)  {      $str = trim($str); //清除字符串兩邊的空格     $str = strip_tags($str,""); //利用php自帶的函數(shù)清除html格式     $str = preg_replace("/t/","",$str); //使用正則表達式替換內(nèi)容,如:空格,換行,并將替換為空。     $str = preg_replace("/rn/","",$str);      $str = preg_replace("/r/","",$str);      $str = preg_replace("/n/","",$str);      $str = preg_replace("/ /","",$str);     $str = preg_replace("/  /","",$str);  //匹配html中的空格     return trim($str); //返回字符串 }

      方法三:

      去除字符串內(nèi)部的空行:

      $str = preg_replace("/(s*?r?ns*?)+/","n",$str);

      去除全部的空行,包括內(nèi)部和頭尾:

      $str = preg_replace('/($s*$)|(^s*^)/m', '',$str);

      相關(guān)學習推薦:php編程(視頻)

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