|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-06-25 13:20 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
Why not using this code? foreach ($table as $key=>$val) { echo $key.":".$val[0].", ".$val[1]."\n"; }