|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-01-25 00:12 UTC] tyrael@php.net
-Status: Open
+Status: Not a bug
[2013-01-25 00:12 UTC] tyrael@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 22:00:02 2025 UTC |
Description: ------------ When we use foreach with reference and use foreach again with the same variable without doing any action, php will alter array: The last value is doubled Test script: --------------- <?php $a = array(1,2,3); $z = $a; foreach ($a as &$b){} foreach ($a as $b){} print_r($a); if ($a != $z) print('bug'); ?> Expected result: ---------------- Array ( [0] => 1 [1] => 2 [2] => 3 ) Actual result: -------------- Array ( [0] => 1 [1] => 2 [2] => 2 ) bug