|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-12-08 10:38 UTC] daverandom@php.net
-Status: Open
+Status: Not a bug
[2017-12-08 10:38 UTC] daverandom@php.net
[2017-12-08 10:41 UTC] danack@php.net
[2017-12-08 10:43 UTC] daverandom@php.net
[2017-12-11 00:28 UTC] a at b dot c dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 23 11:00:01 2025 UTC |
Description: ------------ Using foreach with & for getting address of variable changes last element of array in next foreach Test script: --------------- <?php $values = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4); $sum = 0; foreach ($values as &$value) $value++; foreach ($values as $value) $sum += $value; print_r($values); ?> Expected result: ---------------- Array ( [a] => 2 [b] => 3 [c] => 4 [d] => 5 ) Actual result: -------------- Array ( [a] => 2 [b] => 3 [c] => 4 [d] => 4 )