How can I find out how many times a foreach construct loops in PHP, without using a "counter" variable?
<p>If I have a <code>foreach</code> construct, like this one:</p>

<pre><code>foreach ($items as $item) {
    echo $item . "&lt;br /&gt;";
}
</code></pre>

<p>I know I can keep track of how many times the construct loops by using a counter variable, like this:</p>

<pre><code>$counter = 0;

$foreach ($items as $item) {
    echo $item.' is item #'.$counter. "&lt;br /&gt;";
    $counter++;
}
</code></pre>

<p>But is it possible to do the above <em>without</em> using a "counter" variable?
That is, is it possible to know the iteration count within the <code>foreach</code> loop, <em>without</em> needing a "counter" variable?</p>

<p>Note: I'm totally okay with using counters in my loops, but I'm just curious to see if there is a provision for this built directly into PHP... It's like the awesome <code>foreach</code> construct that simplified certain operations which are clunkier when doing the same thing using a <code>for</code> construct.</p>
