note 32903 deleted from control-structures.foreach by didou
| From: | didou@php.net | Date: | Tue, 10 Jun 2003 15:15:32 +0000 |
| Subject: | note 32903 deleted from control-structures.foreach by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-50108@lists.php.net to get a copy of this message | ||
Note Submitter: php@electricsurfer.com
----
Here's an easy way of seeing if you are on the 1st iteration of a foreach loop:
$list = array('Bananas'=>6,'Apples'=>5,'Oranges'=>3);
foreach (array_keys($list) as $i=>$item)
{
if ($i) echo ', ';
echo $list[$item].' '.$item;
}