Edit report at http://bugs.php.net/bug.php?id=28919&edit=1

 ID:               28919
 User updated by:  black at scene-si dot org
 Reported by:      black at scene-si dot org
 Summary:          foreach does not take list() as argument output
 Status:           Open
 Type:             Feature/Change Request
-Package:          Feature/Change Request
+Package:          *General Issues
 Operating System: any
 PHP Version:      Irrelevant

 New Comment:

It wouldn't be a FEATURE then, would it?


Previous Comments:
------------------------------------------------------------------------
[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] poll...@php.net

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 http://bugs.php.net/bug.php?id=28919&edit=1

Reply via email to