note 44946 added to function.str-replace

From: Date: Fri, 20 Aug 2004 21:04:11 +0000
Subject: note 44946 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-75021@lists.php.net to get a copy of this message
Here's a quick and dirty function for case-insensitive replacement 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; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44946 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44946&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44946&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75021) next »