note 78958 added to function.list
| From: | HayleyWatson at osu1 dot php dot net | Date: | Sun, 04 Nov 2007 20:36:15 +0000 |
| Subject: | note 78958 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131997@lists.php.net to get a copy of this message | ||
In the code by tenz699 at hotmail dot com, the list() construct is taking values from the result of
the each() function, not from the associative array; the example is therefore spurious.
each() returns an array of four elements, indexed in the order 1, 'value', 0,
'key'. As noted in the documentation, the associative keys are ignored, and the
numerically-indexed values are assigned in key order.
<?php
$array = array('foo'=>'bar');
$t = each($array);
print_r($t);
list($a,$b,$c,$d) = $t;
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);
?>
Output:
Array
(
[1] => bar
[value] => bar
[0] => foo
[key] => foo
)
string(3) "foo"
string(3) "bar"
NULL
NULL
----
Server IP: 203.89.181.186
Probable Submitter: 60.234.168.92
----
Manual Page -- http://www.php.net/manual/en/function.list.php
Edit -- https://master.php.net/note/edit/78958
Del: integrated -- https://master.php.net/note/delete/78958/integrated
Del: useless -- https://master.php.net/note/delete/78958/useless
Del: bad code -- https://master.php.net/note/delete/78958/bad+code
Del: spam -- https://master.php.net/note/delete/78958/spam
Del: non-english -- https://master.php.net/note/delete/78958/non-english
Del: in docs -- https://master.php.net/note/delete/78958/in+docs
Del: other reasons-- https://master.php.net/note/delete/78958
Reject -- https://master.php.net/note/reject/78958
Search -- https://master.php.net/manage/user-notes.php