$find = "hi";
$contents = implode(null, file($logfile));
$contents = preg_replace("/($find)/i", "<b
that will replace any $find with your highlighted b. Notice the i at the end
preg expression, that tells it to ignore case. The nice part about that is
that if you search for HI, if finds hi, it will highlight hi, not HI.
"Qartis" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I've got a search script, where you can search for a string and it will
> return links to the HTML files that contain the string. I've also written
> function, where it will highlight each instance of the searched string by
> $asdf = fopen($logfile, "r");
> $contents = fread($asdf,filesize($logfile));
> style=\"color:black;background-color:#FFCC66\">".$hi."</b>", $contents);
> echo $contents;
> (stri_replace because I wrote a function to do that)
> Where $hi is the string that is to be highlighted. Of course, if the user
> searched for HI, and Hi was found, it would show up as a highlighted HI,
> becuase it only uses $hi as the highlighted word, not the original string.
> I'm fairly sure that I could do this with ereg functions, but I've spent
> long looking and now it just about makes me sick just looking at it.
> Pleeease, can anybody help?
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]