note 92079 deleted from function.each by thiago
| From: | thiago@php.net | Date: | Wed, 08 Jul 2009 04:03:22 +0000 |
| Subject: | note 92079 deleted from function.each by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158047@lists.php.net to get a copy of this message | ||
Note Submitter: williamcwilliams at SPAM_ME_NOT dot gmail dot com
----
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.