From: adrian at adecsys dot com
Operating system: WindowsXP
PHP version: 5.2.5
PHP Bug Type: Feature/Change Request
Bug description: Multi-dimensional foreach iterator?
Description:
------------
Suggestion is to support foreach() to iterate actoss multidimensional
arrays.
Given a higher-order array, it would be very useful to be able to collapse
nested foreach statements into a single one. To exemplify:
given
$A[1][1]="A";
$A[1][2]="B";
$A[1][3]="C";
$A[2][1]="D";
etc.
foreach($A as $L1,$L2 => $V) {
// first iteration -- $L1=1, $L2=1, $V="A"
// second iteration -- $L1=1, $L2=2, $V="B"
// third iteration -- $L1=1, $L2=3, $V="C"
// fourth iteration -- $L1=2, $L2=1, $V="D"
}
I would have many uses for such a construct, and I'm hoping that I would
not be alone.
KR
--
Edit bug report at http://bugs.php.net/?id=44530&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44530&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44530&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44530&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44530&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44530&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44530&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44530&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44530&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44530&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44530&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44530&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44530&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44530&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44530&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44530&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44530&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44530&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44530&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44530&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44530&r=mysqlcfg