php 过滤带有html标签的内容
过滤带有html标签的内容 [代码片段(17行)]
function html2text($str){ $str = trim($str); $str = preg_replace("/||<!--(.*)-->/isU","",$str); $alltext = ""; $start = 1; for($i=0;$i31){ $alltext .= $str[$i]; } } } $alltext = str_replace(" "," ",$alltext); $alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext); $alltext = preg_replace("/[ ]+/s"," ",$alltext); $alltext = htmlspecialchars($alltext,ENT_QUOTES); return $alltext; } //该片段来自于http://outofmemory.cn
精彩图集
精彩文章