best way todo a case insensitive str_replace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux