用HTML中的新链接替换关键字

时间:2013-06-10 11:41:35

标签: php

我想用新链接替换所有关键字。 $keyword是一个关键字数组。 $html是网页。 如果找到任何关键字并且它不在titlemeta和其他丰富的html标记内,例如strongbh1等...然后应将其替换为$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);
 }

此代码应用链接。但没有正确检查标签。

0 个答案:

没有答案
相关问题