|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-22 12:38 UTC] post at oliver-schieche dot de
Description:
------------
When assigning an array to a list() of variables and using the input array as a member of that list(), unexpected results are returned.
Reproduce code:
---------------
$b = array('foo','bar');
list($a,$b) = $b;
$c = array('foo','bar');
list($c,$d) = $c;
Expected result:
----------------
$a == $c == 'foo'
$b == $d == 'bar'
Actual result:
--------------
$a == 'b'
$b == 'bar'
$c == 'foo'
$d == 'bar'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 18:00:01 2025 UTC |
Why document an obvious bug instead of fixing it? How would you document/explain this? If this works: function ret($array) {return $array;} $b = array('foo','bar'); list($a,$b) = ret($b); But this doesn't: function &ret(&$array) {return $array;} $b = array('foo','bar'); list($a,$b) = ret($b); Then there's a referencing error hidden somewhere...Hate to be nagging again, but there's still a problem: it works "as it's supposed to" (read: "as it's not documented") in PHP4, but doesn't in PHP5 with the exception, that the following produces expected results: $a = array('Foo','Bar'); list($a,$b) = $a; $a == 'Foo' ==> TRUE $b == 'Bar' ==> TRUE "both variables are needed during the "list" operation." is a somewhat confusing statement regarding the issue(s) above.