note 11517 modified in str_replace by jmcastagnetto

From: Date: Fri, 23 Feb 2001 09:41:57 +0000
Subject: note 11517 modified in str_replace by jmcastagnetto
Groups: php.notes 
Request: Send a blank email to php-notes+get-11460@lists.php.net to get a copy of this message
[Editor's note: Perhaps the wording of the description needs to be even more clear than it is, but the prototype clearly states: mixed str_replace (mixed search, mixed replace, mixed subject) It does not indicate that the function returns (void) or (boolean) as functions that change directly their arguments usually do. And the example should also be a hint on this behaviour, which should make things clear if the description of the process and the prototype did not.] This function does _NOT_ (as the introduction says) "Replace all occurrences of the search string in subject with the replacement string" ... instead it _returns_ a copy of subject with all occurrences of the search string replaced with the replacement string. str_replace("x", "y", $str) does nothing.... $str = str_replace("x", "y", $str) does what the introduction says. http://www.php.net/manual/str-replace.php

« previous php.notes (#11460) next »