Re: best way todo a case insensitive str_replace

From: Date: Mon, 21 Feb 2005 15:59:01 +0000
Subject: Re: best way todo a case insensitive str_replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-209133@lists.php.net to get a copy of this message
http://ar2.php.net/str_ireplace On Mon, 21 Feb 2005 15:54:33 -0000, pmpa <mail.pmpa@sapo.pt> wrote: > Hi all. > > What is the best way to do a string insensitive replace? > Currently I am doing: > > $replace = "g r"; > $arr = explode(" ",$replace); > $text = "PHP is GreaT!"; > for($i=0;i<count($arr);$i++){ > $text = > > str_replace(strtolower($arr[$i]),"<b>".strtolower($arr[$i])."</b>",$text); > $text = > > str_replace(strtoupper($arr[$i]),"<b>".strtoupper($arr[$i])."</b>",$text); > } > > Works except for "Ph","PhP","gr" etc... > I am looking for suggestions before using str_split(); because my $replace > string can be a bit large :) > > Thanks in advance. > > Pedro. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#209133) next »