清除字符串中的非普通字符标记函数
时间:2010-04-19 来源:xhq6632
/*去掉字符中全部其他标记*/
function html2txt($document){
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments ncluding CDATA
);
$text = preg_replace($search, '', $document);
return $text;
}
function html2txt($document){
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments ncluding CDATA
);
$text = preg_replace($search, '', $document);
return $text;
}
相关阅读 更多 +