Convert HTML to text// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<style[^>]*?>.*?</style>'si", // Strip out css
"'<[\/\!]*?[^<>]*?>'si", // Strip out html tags
"'([\r\n])[\s]+'", // Strip out white space
"'&(quot|#34);'i", // Replace html entities
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e"); // evaluate as php$replace = array ("",
"",
"\\1",
"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");$text = preg_replace ($search, $replace, $document);
解决方案 »
- 类中如何调生成其它类对象
- 请教apache怎么配置一个域名指向首页文件,apache的rewrite的写法
- mysql中的单引号问题
- 继续请教,PHP项目如何估计工作量,工时,划分工作职责
- 一个PHP处理两个表单
- 一个引用变量的小例子,报错,请大家帮忙看一下.
- 求助:这是什么错误?关于discuz4.0修改
- C++/PHP下AES加密解密结果不一致
- apache utf8 伪静态中文乱码问题
- Warning: require_once(conn.php): failed to open stream: No such file or director
- 关于“filename.php?mess_id=123”类型描述的问题
- php中能象vc中样创建线程吗?
preg_replace( "#<script.*?>.+?<\/script>#is", "", $str );
//去掉style
preg_replace( "#<style>.+?<\/style>#is", "", $str );然后再strip_tags()...