1

I want to replace all keywords with new link. $keyword is an array of keyword. $html is webpage. If any keyword is found and it is not inside of title, meta and other rich html tags such as strong, b, h1 etc... Then it should be replaced with $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);
 }

This code applying link. but not checking tags correctly.

HamZa
  • 14,671
  • 11
  • 54
  • 75
Hazeena
  • 69
  • 1
  • 3

0 Answers0