|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-07-23 15:27 UTC] aharvey@php.net
-Status: Open
+Status: Bogus
[2010-07-23 15:27 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 22:00:01 2025 UTC |
Description: ------------ I make a loop with a "foreach" and each item is passed by reference. After what I make another loop on the same array with the same item var name, but not by reference this time. Then the last value of the array is replaced by next to last one. Test script: --------------- <?php $idList = array(42, 52, 101010); foreach($idList as &$id) {}; print_r($idList); // => Array ( [0] => 42 [1] => 52 [2] => 101010 ) foreach($idList as $id) {}; print_r($idList); // => Array ( [0] => 42 [1] => 52 [2] => 52 ) // == ?> Expected result: ---------------- Array ( [0] => 42 [1] => 52 [2] => 101010 ) Array ( [0] => 42 [1] => 52 [2] => 101010 ) Actual result: -------------- Array ( [0] => 42 [1] => 52 [2] => 101010 ) Array ( [0] => 42 [1] => 52 [2] => 52)