function GetHtmlText($str)
{
$str = preg_replace("/<sty(.*)//style>|<scr(.*)//script>|<!--(.*)-->/isU","",$str);
$alltext = "";
$start = 1;
for($i=0;$i<strlen($str);$i++){
if($start==0 && $str[$i]==">") $start = 1;
else if($start==1){
if($str[$i]=="<"){ $start = 0; $alltext .= " "; }
else if(ord($str[$i])>32) $alltext .= $str[$i];
}
}
$alltext = preg_replace("/&([^;&]*)(;|&)/"," ",$alltext);
$alltext = preg_replace("/ {1,}/"," ",$alltext);
$alltext = preg_replace("/ {1,}/"," ",$alltext);
return $alltext;
}
获取html中的文本数据
最新推荐文章于 2021-10-27 11:42:50 发布