#33572 [Opn->Bgs]: Behavior of foreach changed
| From: | derick@php.net | Date: | Tue, 05 Jul 2005 08:05:28 +0000 |
| Subject: | #33572 [Opn->Bgs]: Behavior of foreach changed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81391@lists.php.net to get a copy of this message | ||
ID: 33572
Updated by: derick@php.net
Reported By: daniel at bokko dot nl
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Gentoo linux 2.4.22
PHP Version: 4.3.11
New Comment:
Do not file bugs when you have Zend extensions (zend_extension=)
loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache,
APC, Xdebug and ionCube loader. These extensions often modify engine
behavior which is not related to PHP itself.
.
Previous Comments:
------------------------------------------------------------------------
[2005-07-05 10:00:25] daniel at bokko dot nl
Description:
------------
After updrade to php 4.3.11 (from 4.3.4) the behaviour of foreach
changed.
When i do not specify a $key in the foreach statement, the value is
wrong when it's an array.
Reproduce code:
---------------
<pre>
<?php
$array = array();
$array[0] = array('apple', 'banana', 'pear', 'grape');
$array[1] = array('apple', 'banana', 'pear', 'grape');
print_r($array);
echo "\n-----------------\n";
foreach($array AS $v) {
print_r($v);
}
?>
</pre>
Expected result:
----------------
Array
(
[0] => apple
[1] => banana
[2] => pear
[3] => grape
)
Array
(
[0] => apple
[1] => banana
[2] => pear
[3] => grape
)
Actual result:
--------------
Array
(
[0] => Array
(
[0] => apple
[1] => banana
[2] => pear
[3] => grape
)
[1] => 0
)
Array
(
[0] => Array
(
[0] => apple
[1] => banana
[2] => pear
[3] => grape
)
[1] => 1
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33572&edit=1