$word"; $splitted_text=preg_split ("/$word/",$text); # explode would be faster but we need the i for ( $i=0; $i]*$/",$splitted_text[$i] ) ) { # is the word in a html tag ? array_splice($splitted_text,$i,2,$splitted_text[$i] . $word . $splitted_text[$i+1]); $i--; } } $text=implode($replace,$splitted_text); } ?>