hi, the following code replaces all keywords with a linked keyword. However, I would like to use REGEX in order to avoid the manipulation of keywords when they fall within links.
ex: if the keyword is orange
<br>orange</br> would become
<br><a href = “somelink”>orange</a></br>
however I’d like to avoid the following
original string:
<a href = “
string after preg_replace:
<a href = “
code:
[code]
global $mainframe;
$content = $article -> text;
$current = JURI::current();
$keywords = $this -> params->def(‘keywords’);
$words = explode(“,”, $keywords);
$keywordLinks = $this -> params->def(‘links’);
$Links = explode(“,”, $keywordLinks);
$number = count($words);
for($i = 0; $i < $number; $i++)
{
$Links[$i] = ‘<a href = “../plugins/content/keyword.php?destination=’.urlencode($Links[$i]).’&location=’.urlencode($current).’&keyword=’.$words[$i].'”>’.$words[$i].'</a>’;
}
for($i = 0; $i < $number; $i++)
{
$words[$i] = ‘/b’.$words[$i].’b/’;
/*$words[$i] = str_replace(‘ ‘, ”, $words[$i]);*/
}
$content = preg_replace($words, $Links, $content);
$article -> text = $content;