php去掉html标签函数代码

原创
2016-07-25 08:54:20 844浏览
  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_tags php使HTML标签自动补全闭合函数的代码 php实现html标签自动补全的代码



声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
上一条:PHP配置文件详解 php.ini文件详解 下一条:php数据库配置文件实现方法示例

相关文章

查看更多