ID: 24281 Updated by: [EMAIL PROTECTED] Reported By: jimflug2222 at hotmail dot com -Status: Open +Status: Closed Bug Type: Strings related Operating System: GNU/Linux PHP Version: 5CVS-2003-06-21 (dev) New Comment:
This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2003-06-21 17:46:33] jimflug2222 at hotmail dot com Description: ------------ I tried out the new fourth parameter in str_replace to count the number of replacements made (this was using the very latest snapshot), and found that the fourth parameter only works if the variable passed is set already. Reproduce code: --------------- Interactive mode enabled $string = "He had had to have had it"; $newstring = str_replace("had", "foo", $string, $count); print "$count changes were made.\n"; changes were made. $count = 0; $newstring = str_replace("had", "foo", $string, $count); echo $count; 3 (Note: due to ambiguity in the manual, I tried using $count and &$count as I wasn't sure which was correct - both failed to work) Expected result: ---------------- I would have expected either a warning, "Unknown variable $count", or, otherwise, for PHP to create $count and set it to the right value. Actual result: -------------- $count didn't get set ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24281&edit=1