Say I have an array similar to the following and I'm looping through it as such:
$sidebar = array("Best of the Month" => $featuredBestMonth,
"Featured Content" => $featuredContent);
<? while($item = current($sidebar)):?>
<? if($item):?>
<h3><?=key($sidebar);?></h3>
<? foreach($item as $single):?>
<p><?=$single['title'];?></p>
<? endforeach;?>
<? endif;?>
<? next($sidebar);?>
<? endwhile;?>
How can I count the current array number, so the first while would display 1 and the second would display 2?
I know I could do it with $i++; but just wondered if there was an array function to do just this?
Not sure if I can use key with a foreach loop?
foreachloop + counter. You can find a list of array functions here: php.net/manual/en/ref.array.php$single?$itemis not filled any where... :(