|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-10-02 20:39 UTC] rstoll at tutteli dot ch
Description: ------------ see: https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#list and: php.net/manual/en/function.list.php The manual states: Warning list() assigns the values starting with the right-most parameter. If you are using plain variables, you don't have to worry about this. But if you are using arrays with indices you usually expect the order of the indices in the array the same you wrote in the list() from left to right; which it isn't. It's assigned in the reverse order. Right now I cannot really grasp what this warning tries to explain but I can see that it is missing in the spec. Either the manual is wrong or the spec PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 21:00:01 2025 UTC |
The quoted warning describes the result for the following example: list($arr[], $arr[], $arr[]) = array(0, 100, 67); All currently released versions have the resulting $arr like so: array(67, 100, 0); Do note, that this has been changed in php-src's master branch.Or when providing explicit indices: list($arr['a'], $arr['b'], $arr['c']) = array(0, 100, 67); Gives: array('c' => 67, 'b' => 100, 'a' => 0);