Re: Question - foreach.
| From: | Daniel Brown | Date: | Thu, 10 Jun 2010 02:53:04 +0000 |
| Subject: | Re: Question - foreach. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306002@lists.php.net to get a copy of this message | ||
On Wed, Jun 9, 2010 at 21:49, Shreyas <shreyasbr@gmail.com> wrote:
> PHP'ers,
>
> I am reading a PHP book which explains foreach and at the end says : *'When
> foreach starts walking through an array, it moves the pointer to
> the beginning of the array. You don’t need to reset an array before
> walking through it with foreach.'*
> *
> *
> *Does this mean - *
[snip!]
An easy way to think about it: foreach is cocky and doesn't give a
damn about the rules array functions or placements have set in place.
It'll start from the beginning, and to hell with everyone else.
In other words: foreach will iterate wholly; it will count *for*
*each* key in the loop, not just where another portion of the code
left off.
--
</Daniel P. Brown>
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!