PHP 4.0 Bug #7122: reference to array element problem
| From: | gargamel at wizard-labs dot org | Date: | Tue, 10 Oct 2000 16:41:04 +0000 |
| Subject: | PHP 4.0 Bug #7122: reference to array element problem | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-34604@lists.php.net to get a copy of this message | ||
From: gargamel@wizard-labs.org
Operating system: Linux
PHP version: 4.0.2
PHP Bug Type: Scripting Engine problem
Bug description: reference to array element problem
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
--
Edit Bug report at: http://bugs.php.net/?id=7122&edit=1