如下数据……
<font color=black >设计
<font color=red ><b>广告
<font color=green > 艺术
当前字段数据(有这几种类型),我想将html替换为空!求一正则!!!
目前我是:replace(str,'<font color=','');但是不行,数据量比较大。
<font color=black >设计
<font color=red ><b>广告
<font color=green > 艺术
当前字段数据(有这几种类型),我想将html替换为空!求一正则!!!
目前我是:replace(str,'<font color=','');但是不行,数据量比较大。
/**
* 转换字符串为纯文本
* @param $document string 文本
* @return $text 纯文本
* **/function html2txt($document)
{
$search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA
);
$text = preg_replace($search, '', $document);
return $text;
}
或者用程序lun吧