RE: [PHP] using a counter in a foreach loop
| From: | Matt Schroebel | Date: | Tue, 26 Mar 2002 14:50:57 +0000 |
| Subject: | RE: [PHP] using a counter in a foreach loop | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-90189@lists.php.net to get a copy of this message | ||
$i = 1;
foreach ($months) {
// do some things
$i++;
}
> -----Original Message-----
> From: Erik Price [mailto:pricee@hhbrown.com]
> Sent: Tuesday, March 26, 2002 9:49 AM
>
> I have a foreach loop, where I execute some commands for each
> element in
> a certain array. One thing I would like to add to this loop is a
> counter, so that on each iteration of the loop I have a next higher
> number. The following does not work:
>
> foreach ($months) {
> $i = 1;
> // do some things
> $i++;
> }
>