Edit report at https://bugs.php.net/bug.php?id=10203edit=1
ID: 10203
Patch added by: larue...@php.net
Reported by:jack at mobil dot cz
Summary:allow foreach($array as list($a,$b)
Status: Analyzed
Type: Feature/Change Request
Package:Scripting Engine problem
Operating System: *
PHP Version:*
Block user comment: N
Private report: N
New Comment:
The following patch has been added/updated:
Patch Name: php-5.4.0-alpha1-foreach-list-diff.patch
Revision: 1309930450
URL:
https://bugs.php.net/patch-display.php?bug=10203patch=php-5.4.0-alpha1-foreach-list-diff.patchrevision=1309930450
Previous Comments:
[2002-01-29 04:19:59] yohg...@php.net
It's in TODO already :)
Someone might implement it, but I guess it's not anytime soon.
[2002-01-29 03:34:06] jack at mobil dot cz
you haven't read the previous posts, have you?
I think it's a general problem with list() construct, that you cannot use it
everywhere you can use an L-value (or however you guys call it in PHP)
[2002-01-28 20:45:41] yohg...@php.net
foreach ($arr as $key = $val)
[2001-04-06 14:42:55] tor...@php.net
It's for someone else to decide whether to add this to
the language, but until they do you can achieve the same
effect with:
$arr = array(array(1, 2), array(3, 4));
foreach ($arr as $narr) {
list($a, $b) = array_values($narr);
echo $a, $b\n;
}
BTW--it would have helped if you had explained what
results you were after and not just the syntax you wanted. ;)
[2001-04-06 07:54:29] jack at mobil dot cz
no, 'list' should assign an array to a list of variables.
$arr = array(array(1, 2), array(3, 4));
foreach ($arr as list($a, $b))
echo $a $b\n;
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=10203
--
Edit this bug report at https://bugs.php.net/bug.php?id=10203edit=1