I've been trying to find a way through this, but it's just getting frustrating... The closest info I've found about this was in thread434-523609 but the problem there is different from mine.
I need to go over an html file and highlight words or part of words in it (kind of what you get at the end of a search engine result like google). The problem is, I don't want words within html tags, any html tag, to be highlighted.
For example,
$text="<br>let's bring the house down<br><center>Here we are in the center of town</center>"
key words for searching - br AND center
What I want to get is![[thumbsup] [thumbsup] [thumbsup]](/data/assets/smilies/thumbsup.gif)
$text="<br>let's <b>br</b>ing the house down<br><center>Here we are in the <b>center</b> of town</center>"
and not![[thumbsdown] [thumbsdown] [thumbsdown]](/data/assets/smilies/thumbsdown.gif)
$text="<<b>br</b>>let's <b>br</b>ing the house down<<b>br</b>><<b>center</b>>Here we are in the <b>center</b> of town</<b>center</b>>"
The basic idea is that I have an array of the keywords to search for $keys_arr, where all the values are of the form "/$word/si". The replace array $replace_arr has values of the form "<b>$word</b>". The action line is
$text = preg_replace($keys_arr,$replace_arr,$text);
I'm pretty sure there should be some regular expression solution, but I just can't seem to find it :
Thanks![[3eyes] [3eyes] [3eyes]](/data/assets/smilies/3eyes.gif)
I need to go over an html file and highlight words or part of words in it (kind of what you get at the end of a search engine result like google). The problem is, I don't want words within html tags, any html tag, to be highlighted.
For example,
$text="<br>let's bring the house down<br><center>Here we are in the center of town</center>"
key words for searching - br AND center
What I want to get is
![[thumbsup] [thumbsup] [thumbsup]](/data/assets/smilies/thumbsup.gif)
$text="<br>let's <b>br</b>ing the house down<br><center>Here we are in the <b>center</b> of town</center>"
and not
![[thumbsdown] [thumbsdown] [thumbsdown]](/data/assets/smilies/thumbsdown.gif)
$text="<<b>br</b>>let's <b>br</b>ing the house down<<b>br</b>><<b>center</b>>Here we are in the <b>center</b> of town</<b>center</b>>"
The basic idea is that I have an array of the keywords to search for $keys_arr, where all the values are of the form "/$word/si". The replace array $replace_arr has values of the form "<b>$word</b>". The action line is
$text = preg_replace($keys_arr,$replace_arr,$text);
I'm pretty sure there should be some regular expression solution, but I just can't seem to find it :
Thanks
![[3eyes] [3eyes] [3eyes]](/data/assets/smilies/3eyes.gif)