Home > php教程 > php手册 > PHP自定义函数:去除所有html标签

PHP自定义函数:去除所有html标签

WBOY
Release: 2016-06-13 10:39:58
Original
1348 people have browsed it

PHP自定义函数:去除所有html标签

  1. function pregstring($str){
  2.     $strtemp = trim($str);
  3.     $search = array(
  4.         "||Uis",
  5.         "|<script>].*?</script>|Uis", // 去掉 javascript
  6.         "|[字定义].*[/字定义]|Uis", // 去掉缩略图
  7.         "|]*?>|Uis", // 去掉 HTML 标记
  8.         ">(quot|#34);i", // 替换 HTML 实体
  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(字符串); //调用函数
  31. ?>

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template