Doc #65221 [Com]: Does not adequately explain nature of how list retrieves values from an array
| From: | lucas at threeamdesign dot com dot au | Date: | Tue, 09 Jul 2013 06:42:30 +0000 |
| Subject: | Doc #65221 [Com]: Does not adequately explain nature of how list retrieves values from an array | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10058@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65221&edit=1
ID: 65221
Comment by: lucas at threeamdesign dot com dot au
Reported by: lucas at threeamdesign dot com
Summary: Does not adequately explain nature of how list
retrieves values from an array
Status: Open
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Sorry, missed that note. I'm sure many others have and will. I still think it needs the
example.
Previous Comments:
------------------------------------------------------------------------
[2013-07-09 04:28:27] gabri dot ns at gmail dot com
it is already mentioned in a note at the bottom of the page.
still, its true that it would be better if thus note moved up
at the main description.
------------------------------------------------------------------------
[2013-07-09 03:53:53] lucas at threeamdesign dot com
Description:
------------
---
From manual page: http://www.php.net/function.list
---
The main description for the construct should specify that it only operates on numeric indices of an
array (i.e. string keys are ignored) and expects them to be consecutive and starting at 0. It should
also state that the order in which the indices were defined is irrelevant.
Test script:
---------------
This behaviour could be explained clearly, like so:
<?php
$foo = array(2 => 'a', 'foo' => 'b', 0 => 'c');
$foo[1] = 'd';
list($x, $y, $z) = $foo;
var_dump($foo, $x, $y, $z);
?>
produces the following result:
array(4) {
[2]=>
string(1) "a"
["foo"]=>
string(1) "b"
[0]=>
string(1) "c"
[1]=>
string(1) "d"
}
string(1) "c"
string(1) "d"
string(1) "a"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65221&edit=1