highlighting searchterms as bold text

From: Date: Thu, 20 Sep 2007 10:30:47 +0000
Subject: highlighting searchterms as bold text
Groups: php.general 
Request: Send a blank email to php-general+get-262272@lists.php.net to get a copy of this message
Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with "ethyl": a) replace "ethyl" by "<b>ethyl</b>" b) replace "Ethyl" by "<b>Ethyl</b>" c) replace "ethylene" by "<b>ethylene</b>" d) but not "methyl" by "<b>methyl</b>" Now I use: $patterns[0] = "/ethyl/"; $replacements[0] = "<b>ethyl</b>"; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor

« previous php.general (#262272) next »