Re: Add a bgcolor - regular expressions

From: Date: Mon, 26 Jan 2004 13:45:06 +0000
Subject: Re: Add a bgcolor - regular expressions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175752@lists.php.net to get a copy of this message
> $string = "PHP core developers & Php Programmers." > $result = "<span style='background:#DDDDDD'>PHP</span> core > developers & > <span style='background:#DDDDDD'>Php</span> Programmers." $key = "php"; $string = "PHP core developers & Php Programmers."; $result = preg_replace("#($key)#si", "<span style='background-color: #dddddd;'>\\1</span>", $string); Hidayet Dogan hidayet.dogan@pleksus.com.tr Pleksus Bilisim Teknolojileri D.T.O. A.S. ---------------------------------------------------------- caldiran sok. 14/6 06420 kolej ankara * www.pleksus.com.tr tel : +90 312 4355343 * faks: +90 312 4354006 On Mon, 26 Jan 2004, Sheni R. Meledath wrote: > Hi, > > I am looking for a pattern/function which can be used to insert a > background color for a word in a string. > > I want to use this for a keyword search application where the words entered > are highlighted in the results display. If I do a direct replace the case > of the text in the string cannot be maintained. > > For eg: > $string = "PHP core developers & Php Programmers." > $result = "<span style='background:#DDDDDD'>PHP</span> core > developers & > <span style='background:#DDDDDD'>Php</span> Programmers." > > > Sheni R Meledath > sheni@cyber-gear.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#175752) next »