From: esartoni at omniaglobal dot net
Operating system: Linux
PHP version: 4CVS-2004-10-20 (stable)
PHP Bug Type: Arrays related
Bug description: foreach wrong assignment with multidim arrays
Description:
------------
foreach doesn't work as expected when using multidimensional arrays.
Reproduce code:
---------------
<?php
$a=array();
$a[]=array("one", "two", "three");
$a[]=array("five", "six", "seven");
// Code 1 (THIS DON'T WORK AS EXPECTED)
foreach ($a as $value) {
echo join(",", $value)."\n";
}
/*
This code below is a workaround:
// Code 2 (THIS WORKS!)
foreach ($a as $key => $value) {
echo join(",", $value)."\n";
}
*/
?>
Expected result:
----------------
one,two,three
five,six,seven
Actual result:
--------------
Array,0
Array,1
--
Edit bug report at http://bugs.php.net/?id=30496&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30496&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30496&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30496&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30496&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30496&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30496&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30496&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30496&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30496&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30496&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30496&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30496&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30496&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30496&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30496&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30496&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30496&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30496&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30496&r=mysqlcfg