Home > Backend Development > PHP Tutorial > PHP custom function: remove all html tags_PHP tutorial

PHP custom function: remove all html tags_PHP tutorial

WBOY
Release: 2016-07-13 17:41:09
Original
803 people have browsed it

PHP custom function: remove all html tags

  1. function pregstring($str){
  2. $strtemp = trim($str);
  3. $search = array(
  4. "||Uis",
  5. "|].*?< /script>|Uis", // Remove javascript
  6. "|[Word definition].*[/Word definition]|Uis", // Remove thumbnail
  7. "|<[ /!].*?[^<>]*?>|Uis", // Remove the HTML tag
  8.               ">(quot|#34);i", // Replace the HTML entity
  9. ">(amp|#38);i",
  10. "|,|Uis",
  11. "|[s]{2,}|is" ,
  12. “[>nbsp;]isu”,
  13. “|[$]|Uis”,
  14. );
  15. $replace = array (
  16. "` ",
  17. " ",
  18. " ",
  19. " ",
  20. " ",
  21. "",
  22. "",
  23. " ",
  24. " ",
  25. " ",
  26. );
  27. $text = preg_replace($search, $replace, $strtemp);
  28. return $text;
  29. }
  30. echo pregstring(string) ; //Call function
  31. ?>

http://www.bkjia.com/PHPjc/486145.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486145.htmlTechArticlePHP custom function: remove all html tags?php function pregstring($str){ $strtemp = trim($ str); $search = array( "||Uis", "|script[^].*?/script|Uis", // Remove javascript "|[字定...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template