我想用新链接替换所有关键字。$keyword是一个关键字数组。$html是网页。如果找到任何关键字并且它不在内部title,meta以及其他丰富的html标签,例如strong,b等h1......那么它应该被替换为$replace。
foreach($keywords as $key2 => $keyword)
{
$keyword = trim($keyword);
$replace = '<a href="'.$row['url'].'" title="'.$row['alt'].'" class="linking"'.$nofollow.'>'.$keyword.'</a>';
$html = preg_replace("/".$keyword."(?!([^<]+)?>)/".$case_insensitive, $replace, $html, $times);
}
此代码应用链接。但没有正确检查标签。