note 92079 added to function.each
| From: | williamcwilliams at SPAM_ME_NOT dot gmail dot com | Date: | Wed, 08 Jul 2009 03:52:18 +0000 |
| Subject: | note 92079 added to function.each | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158043@lists.php.net to get a copy of this message | ||
Call me a NOOB, but even with pyxl's comment at the very beginning, I do not understand how the
code block in Example #2 echos each key and value of $fruit.
Even though pyxl explains: "Well, upon executing that code, it turns out that the first two
array elements of the 4 element array that each() creates are assigned to those two variables, and
the last two array element values are just thrown away", I would think that the "first two
array elements" that each($fruits) spits out be [1] => 'apple', [value] =>
'apple' and "the last two element values [to be] thrown away" be [0] =>
'a', [key] => 'a'. Would that not be consistent with the demonstration of
each() in Example #1? In order to avoid asking a question, I humbly request that someone explain one
more time how 'a' ends up being passed to $key and 'apple' to $val in Example
#2.
----
Server IP: 69.147.83.197
Probable Submitter: 75.70.116.230
----
Manual Page -- http://www.php.net/manual/en/function.each.php
Edit -- https://master.php.net/note/edit/92079
Del: integrated -- https://master.php.net/note/delete/92079/integrated
Del: useless -- https://master.php.net/note/delete/92079/useless
Del: bad code -- https://master.php.net/note/delete/92079/bad+code
Del: spam -- https://master.php.net/note/delete/92079/spam
Del: non-english -- https://master.php.net/note/delete/92079/non-english
Del: in docs -- https://master.php.net/note/delete/92079/in+docs
Del: other reasons-- https://master.php.net/note/delete/92079
Reject -- https://master.php.net/note/reject/92079
Search -- https://master.php.net/manage/user-notes.php