Edit report at https://bugs.php.net/bug.php?id=28919&edit=1
ID: 28919 Updated by: [email protected] Reported by: black at scene-si dot org Summary: foreach does not take list() as argument output -Status: Open +Status: Closed Type: Feature/Change Request Package: *General Issues Operating System: any PHP Version: Irrelevant -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: This has been implemented for PHP 5.5. Previous Comments: ------------------------------------------------------------------------ [2010-05-12 08:39:37] black at scene-si dot org It wouldn't be a FEATURE then, would it? ------------------------------------------------------------------------ [2010-05-11 17:39:51] rc at opelgt dot org Why not using this code? foreach ($table as $key=>$val) { echo $key.":".$val[0].", ".$val[1]."\n"; } ------------------------------------------------------------------------ [2004-06-25 19:48:45] [email protected] This is expected behavior. list() is a left-hand language construct and not currently intended to be used this way. Reclassifying to Feature/Change Request. ------------------------------------------------------------------------ [2004-06-25 13:20:05] black at scene-si dot org Description: ------------ Requesting additional functionality for foreach? Reproduce code: --------------- $table = array(); $table['username'] = array(1,"John doe"); $table['black'] = array(2,"Jane doe"); $table['yawn'] = array(3,"Undefined"); foreach ($table as $key=>list($id,$title)) { echo $key.":".$id.", ".$title."\n"; } foreach ($table as list($id,$title)) { echo $id.", ".$title."\n"; } Expected result: ---------------- username:1, John doe black:2, Jane doe yawn:3, Undefined 1, John doe 2, Jane doe 3, Undefined Actual result: -------------- Parse error ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=28919&edit=1
