在写采集程序时,往往需要对采集回来的内容进行处理,比如删除HTML代码、去掉多余的空格、删除回车换行符等等。下面就写一个函数来处理。
function DeleteHtml($str)
{
$str = trim($str);
$str = strip_tags($str,"");
$str = ereg_replace("\t","",$str);
$str = ereg_replace("\r\n","",$str);
$str = ereg_replace("\r","",$str);
$str = ereg_replace("\n","",$str);
$str = ereg_replace(" "," ",$str);
return trim($str);
}