|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68136 list intrinsic starting with the right-most parameter
Submitted: 2014-10-02 20:39 UTC Modified: 2016-11-11 21:53 UTC
From: rstoll at tutteli dot ch Assigned: nikic (profile)
Status: Closed Package: PHP Language Specification
PHP Version: 5.6.0 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: rstoll at tutteli dot ch
New email:
PHP Version: OS:


 [2014-10-02 20:39 UTC] rstoll at tutteli dot ch


The manual states:
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-22 19:14 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.
 [2014-11-22 19:15 UTC]
Or when providing explicit indices:

    list($arr['a'], $arr['b'], $arr['c']) = array(0, 100, 67);


    array('c' => 67, 'b' => 100, 'a' => 0);
 [2016-11-11 21:53 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2016-11-11 21:53 UTC]
As of PHP 7.0 list assignment occur left-to-right. The spec covers this in the sentence "The assignments must occur in this order.".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Feb 27 19:01:28 2024 UTC