I am struggling.. I use this simple code for searching words in text and add relevant texts:
$search=array("/\bword1\b/","/\bword2\b/","/\bword3\b/");
$replace=array("<a href='link1'>word1</a>",ecc);
preg_replace($search,$replace,$myText);
Problem comes when one of the search pattern is found between a html inside $myText. Example:
$myText="blablablabla <strong class="word1">sad</strong>";
As you can see word1 is a css class for the link. If i run the preg_replace will destroy every markup there.
How can I edit my $search pattern for not matching inside html, something like: [^<.?*>] ?
Thanks