note 52328 added to function.str-ireplace

From: Date: Wed, 27 Apr 2005 22:53:59 +0000
Subject: note 52328 added to function.str-ireplace
Groups: php.notes 
Request: Send a blank email to php-notes+get-88666@lists.php.net to get a copy of this message
One more correction to the str_Ireplace function below: the strpos output should be compared against false, otherwise needles in the beginning of haystacks will not be replaced: function str_Ireplace($needle, $replacement, $haystack) { $i = 0; while (($pos = strpos(strtolower($haystack), strtolower($needle), $i)) !== false) { $haystack = substr($haystack, 0, $pos) . $replacement . substr($haystack, $pos + strlen($needle)); $i = $pos + strlen($replacement); } return $haystack; } ---- Manual Page -- http://www.php.net/manual/en/function.str-ireplace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52328 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52328&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52328&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52328&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52328&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52328&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52328&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88666) next »