Doc #68136 [Opn]: list intrinsic starting with the right-most parameter

From: Date: Sat, 22 Nov 2014 19:16:00 +0000
Subject: Doc #68136 [Opn]: list intrinsic starting with the right-most parameter
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11696@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68136&edit=1 ID: 68136 Updated by: salathe@php.net Reported by: rstoll at tutteli dot ch Summary: list intrinsic starting with the right-most parameter Status: Open Type: Documentation Problem Package: PHP Language Specification PHP Version: 5.6.0 Block user comment: N Private report: N New Comment: Or when providing explicit indices: list($arr['a'], $arr['b'], $arr['c']) = array(0, 100, 67); Gives: array('c' => 67, 'b' => 100, 'a' => 0); Previous Comments: ------------------------------------------------------------------------ [2014-11-22 19:14:03] salathe@php.net 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-10-02 20:39:26] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68136&edit=1

« previous php.doc.bugs (#11696) next »