title: Knowning at which point we are in a foreach
body: <p>I have an array:</p>
  
  <pre><code>$array=array('key1'=&gt;'value1','key2'=&gt;'value2','value3');
  </code></pre>
  
  <p>and a foreach:</p>
  
  <pre><code>foreach($array as $v){
       //do something
  }
  </code></pre>
  
  <p>Is there a way to know in the foreach which element we are parsing?</p>
  
  <p>(without doing something like:)</p>
  
  <pre><code>$count=0;
  foreach($array as $v){
      $count++;
      // do something
  }
  </code></pre>
  
  <p>thanks</p>
  
  <p>EDIT1:</p>
  
  <p>Sorry maybe I was not clear:
  I don't want know the key, but I need to know how many elements are left in the foreach. (that's why I did the example with $count)</p>