title: Peek ahead when iterating an array in PHP
body: <p>Is it possible to "peek ahead" while iterating an array in PHP 5.2? For example, I often use foreach to manipulate data from an array:</p>
  
  <pre><code>foreach($array as $object) {
    // do something
  }
  </code></pre>
  
  <p>But I often need to peek at the next element while going through the array. I know I could use a <code>for</code> loop and reference the next item by it's index (<code>$array[$i+1]</code>), but it wouldn't work for associative arrays. Is there any elegant solution for my problem, perhaps involving SPL?</p>