有时候需要清除文章中一些垃圾HMTL代码,有很多网友不知道方法,其实php清除HTML标记满简单的,下面给出解决方法:
<?
function Text2Html($txt){
$txt = str_replace(" "," ",$txt);
$txt = str_replace("<","<",$txt);
$txt = str_replace(">",">",$txt);
$txt = preg_replace("/[rn]{1,}/isU","
rn",$txt);
return $txt; }
?>
看完后是不是觉得满简单了,主要是要替换和正则表达式