|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-10-11 10:36 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 10 04:00:01 2026 UTC |
Creating a reference to an array element prevents that particular element from being listed in a foreach-loop. Instead, the previous element in the array is processed twice. Simple PHP script to reproduce the problem: --------------- <?php $A = array( 'a' => 'A', 'b' => 'B', 'c' => 'C'); /* This works: */ foreach ($A as $y => $x) { echo "y=$y x=$x\n"; } /* This breaks: */ $x = &$A['b']; foreach ($A as $y => $x) { echo "y=$y x=$x\n"; } ?> ------------------- This results in the following output: --------------------- X-Powered-By: PHP/4.0.2 Content-type: text/html y=a x=A y=b x=B y=c x=C y=a x=A y=b x=A <== ERROR!! y=c x=C ------------------- Note: I think this is possibly related to bug id #6417