Home > Backend Development > PHP Tutorial > Filter content with html tags

Filter content with html tags

WBOY
Release: 2016-07-25 09:09:45
Original
1021 people have browsed it

For details, please refer to
Zhou Xiaoshe’s Secret Garden---- PHP Handwriting Method for Filtering HTML Characters
http://zhousir.net/php-html-filtering-method-handwritten-characters.html

  1. function html2text($str){
  2. $str = trim($str);
  3. $str = preg_replace("/||/isU","" ,$str);
  4. $alltext = "";
  5. $start = 1;
  6. for($i=0;$i31){
  7. $alltext .= $str[$i];
  8. }
  9. }
  10. }
  11. $ alltext = str_replace(" "," ",$alltext);
  12. $alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext);
  13. $alltext = preg_replace("/[ ]+/s"," ",$alltext);
  14. $alltext = htmlspecialchars($alltext,ENT_QUOTES);
  15. return $alltext;
  16. }
Copy code


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