Extract a string from a string

From: Date: Wed, 02 Jan 2002 11:54:46 +0000
Subject: Extract a string from a string
Groups: php.general 
Request: Send a blank email to php-general+get-79214@lists.php.net to get a copy of this message
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 a function, where it will highlight each instance of the searched string by using: $asdf = fopen($logfile, "r"); $contents = fread($asdf,filesize($logfile)); fclose($asdf); $contents=stri_replace($hi,"<b 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 too long looking and now it just about makes me sick just looking at it. Pleeease, can anybody help? -qartis

« previous php.general (#79214) next »