This function is pulled straight off the php.net site under the str_replace function, written by: dbergeron [at] clincab [dot] com
I used it a while go on a site for highlighting text, should be fine.
Code
<?php
function highlight($x,$var) {//$x is the string, $var is the text to be highlighted
if ($var != "") {
$xtemp = "";
$i=0;
while($i<strlen($x)){
if((($i + strlen($var)) <= strlen($x)) && (strcasecmp($var, substr($x, $i, strlen($var))) == 0)) {
//this version bolds the text. you can replace the html tags with whatever you like.
$xtemp .= "<b>" . substr($x, $i , strlen($var)) . "</b>";
$i += strlen($var);
}
else {
$xtemp .= $x{$i};
$i++;
-- This message may have been cut off and the rest will only be shown to members. To become a member, click here --