note 23361 added to function.str-replace

From: Date: Tue, 16 Jul 2002 15:24:48 +0000
Subject: note 23361 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-33133@lists.php.net to get a copy of this message
*** stri_replace function *** I found this while searching on google. It works pretty well. Only drawback is that it makes the string your searching for lowercase in the final result ORIGINAL POST "Author: Josh Date: 2001-11-20 23:16:56 Subject: RE: A case-insensitive str_replace() ?? I had to figure this one out ;) I guess if you can not use any regular-expression compatible replacement, this one should do the trick for you... Properly named stri_replace(): function stri_replace($replacer,$replacement,$string) { $lowercase_replacer = strtolower($replacer); // Make all the words we are replacing lowercase $string = str_replace($replacer,$lowercase_replacer,$string); // Replace all occurences $string = str_replace($lowercase_replacer,$replacement,$string); return $string; } It works exactly like str_replace() as far as arguments go. I tested this on PHP 4.2.0-dev incase you have any problems (You shouldn't). Hope this helps. -Josh B" END ORIGINAL POST -Chris -- http://www.php.net/manual/en/function.str-replace.php http://master.php.net/manage/user-notes.php?action=edit+23361 http://master.php.net/manage/user-notes.php?action=delete+23361 http://master.php.net/manage/user-notes.php?action=reject+23361

« previous php.notes (#33133) next »