title: Does PHP Have a "built-in" iterator in a Foreach loop?
body: <p>I'm using a foreach loop to go through the REQUEST array, as I want to have an easy way to utilize the REQUEST array's keys and values.</p>
  
  <p>However, I also want to have a numerical index of how many times the loop has run, as I'm writing a spreadsheet with PHPExcel, and I want to use the <code>SetCellValue</code> function. I'm thinking something like this:</p>
  
  <pre><code>foreach( $_REQUEST as $key =&gt; $value){
      $prettyKeys = ucwords(preg_replace($patt_underscore," ",preg_replace($patt_CC,"_",$key)));
      $prettyVals = ucwords(preg_replace($patt_underscore," ",preg_replace($patt_CC,"_",$value)));
      // Replace CamelCase with Underscores, then replace the underscores with spaces and then capitalize string
      // "example_badUsageOfWhatever" ==&gt; "Example Bad Usage Of Whatever"
  
  
      $myExcelSheet-&gt;getActiveSheet()-&gt;SetCellValue( "A". $built-in-foreach-loop-numerical-index ,$prettyKeys);
      $myExcelSheet-&gt;getActiveSheet()-&gt;SetCellValue( "B". $built-in-foreach-loop-numerical-index ,$prettyVals);
  }
  </code></pre>
  
  <p>I know I can easily implement something like <code>$c = 0</code> outsite the foreach and then just increment it each time the loop is run, but is there something cleaner?</p>