Jump to content

Foreach loop counting - please help!


icklechurch

Recommended Posts

Is it possible to get the number of the loop when you are in a foreach statement?

 

For example I have the following foreach loop:

 

<?

foreach ($basket["records"] as $key => $record):

 

LOTS OF CODE HERE

 

?>

 

Is it possible to create an integer so that the first time the loop goes we have a variable called (for example) $i = 1...the second time it loops we have $i = 2 and so on?!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/150297-foreach-loop-counting-please-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.