php去掉html標籤函數代碼

來源:互聯網
上載者:User
  1. function noHTML($content)
  2. {
  3. $content = preg_replace("/]*>/i",'', $content);
  4. $content = preg_replace("/<\/a>/i", '', $content);
  5. $content = preg_replace("/]*>/i",'', $content);
  6. $content = preg_replace("/<\/div>/i",'', $content);
  7. $content = preg_replace("/]*>/i",'', $content);
  8. $content = preg_replace("/<\/font>/i",'', $content);
  9. $content = preg_replace("/]*>/i",'', $content);
  10. $content = preg_replace("/<\/p>/i",'', $content);
  11. $content = preg_replace("/]*>/i",'', $content);
  12. $content = preg_replace("/<\/span>/i",'', $content);
  13. $content = preg_replace("/<\?xml[^>]*>/i",'', $content);
  14. $content = preg_replace("/<\/\?xml>/i",'', $content);
  15. $content = preg_replace("/]*>/i",'', $content);
  16. $content = preg_replace("/<\/o:p>/i",'', $content);
  17. $content = preg_replace("/]*>/i",'', $content);
  18. $content = preg_replace("/<\/u>/i",'', $content);
  19. $content = preg_replace("/]*>/i",'', $content);
  20. $content = preg_replace("/<\/b>/i",'', $content);
  21. $content = preg_replace("/]*>/i",'', $content);
  22. $content = preg_replace("/<\/meta>/i",'', $content);
  23. $content = preg_replace("//i",'', $content);//注釋內容
  24. $content = preg_replace("/]*-->/i",'', $content);//注釋內容
  25. $content = preg_replace("/style=.+?['|\"]/i",'',$content);//去除樣式
  26. $content = preg_replace("/class=.+?['|\"]/i",'',$content);//去除樣式
  27. $content = preg_replace("/id=.+?['|\"]/i",'',$content);//去除樣式
  28. $content = preg_replace("/lang=.+?['|\"]/i",'',$content);//去除樣式
  29. $content = preg_replace("/width=.+?['|\"]/i",'',$content);//去除樣式
  30. $content = preg_replace("/height=.+?['|\"]/i",'',$content);//去除樣式
  31. $content = preg_replace("/border=.+?['|\"]/i",'',$content);//去除樣式
  32. $content = preg_replace("/face=.+?['|\"]/i",'',$content);//去除樣式
  33. $content = preg_replace("/face=.+?['|\"]/",'',$content);
  34. $content = preg_replace("/face=.+?['|\"]/",'',$content);
  35. $content=str_replace( " ","",$content);
  36. return $content;
  37. }
複製代碼

>>> 您可能感興趣的文章:PHP刪除html標籤的代碼php 判斷字串是否包含html標籤提取html標籤的php程式碼範例php提取HTML標籤的方法舉例php去除HTML標籤的二種方法php 去除多餘的HTML標籤php正則 尋找html中包含id屬性的html標籤php用strip_tags完整去除所有html標籤的執行個體分享php刪除html標籤的三種方法分享php刪除html標籤及字串中html標籤的代碼php刪除字串中html標籤的函數提取html標籤的php代碼php正則過濾html標籤、空格、分行符號等的程式碼範例修複未正常關閉的HTML標籤(支援嵌套和就近閉合)的代碼php去除html標籤獲得輸入純文字文檔strip_tagsphp使HTML標籤自動補全閉合函數的代碼php實現html標籤自動補全的代碼

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.