note 44947 deleted from function.str-replace by tomsommer

From: Date: Fri, 20 Aug 2004 21:25:10 +0000
Subject: note 44947 deleted from function.str-replace by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75025@lists.php.net to get a copy of this message
Note Submitter: duerra at blah dot pushitlive dot blah dot net ---- Here's a quick and dirty function for case-insensitive replacment for users not on PHP5 yet: <?PHP function my_str_ireplace($find, $replace, $subject) { $compFind = strtolower($find); $compSubj = strtolower($subject); $findlen = strlen($find); $replacelen = strlen($replace); $loc = 0; while(($loc = strpos($compSubj, $compFind, $loc)) !== FALSE) { $bef = substr($subject, 0, $loc); $aft = substr($subject, $loc+$findlen); $subject = $bef.$replace.$aft; $loc = $loc + $replacelen; } return $subject; } ?>

« previous php.notes (#75025) next »