|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-09-24 21:26 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2018-09-24 21:26 UTC] requinix@php.net
[2018-09-24 21:48 UTC] spam2 at rhsoft dot net
[2018-09-24 21:50 UTC] spam2 at rhsoft dot net
[2018-09-24 21:57 UTC] kellnerdenes at gmail dot com
[2018-09-24 22:02 UTC] requinix@php.net
[2018-09-24 22:27 UTC] spam2 at rhsoft dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Mar 26 13:00:01 2026 UTC |
Description: ------------ When looping along an array twice, first by reference, then by just normal value, the last element gets affected (gets the value of the second-last). So while it should display "first second third fourth", it will give "first second third third" instead. Commenting any of the foreaches or changing their order makes the problem disappear. I've seen similar reports but I think this one is clearly a bug while others seem to be unsure. Test script: --------------- $a = explode("\n","first\nsecond\nthird\nfourth"); foreach($a as &$x); foreach($a as $x); print_r($a); Expected result: ---------------- Array ( [0] => first [1] => second [2] => third [3] => fourth ) Actual result: -------------- Array ( [0] => first [1] => second [2] => third [3] => third )