Thread: str_replace??
View Single Post
Old 09-22-2008, 01:41 PM   #1 (permalink)
CoryMathews
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default str_replace??

I have this code

PHP Code:
$highlightWords explode(" "$searchString);
$s sizeof($highlightWords);
for(
$i=0;$i<=$s;$i++) {
$info str_replace($highlightWords[i], "<span class=\"highlight\">$highlightWords[i]</span>"$info);

And it does not work. However If i just do
PHP Code:
$info str_replace($highlightWords[0], "<span class=\"highlight\">$highlightWords[0]</span>"$info); 
without the loop it seems to work.

My array contains a couple words that were entered into the search bar.

What i am doing with this code is searching a string and highlighting everywhere that a searched word appears.

any ideas?
CoryMathews is offline  
Reply With Quote