title: Reset the Internal Pointer Value of a PHP Array (ArrayObject)
body: <p>Consider a simple PHP ArrayObject with two items.</p>
  
  <pre><code>$ao = new ArrayObject();
  $ao[] = 'a1';  // [0] =&gt; a1
  $ao[] = 'a2';  // [1] =&gt; a2
  </code></pre>
  
  <p>Then delete the last item and add a new item.</p>
  
  <pre><code>$ao-&gt;offsetUnset(1);
  $ao[] = 'a3';  // [2] =&gt; a3
  </code></pre>
  
  <p>I'd very much like to be able to have 'a3' be [1].</p>
  
  <p>How can I reset the internal pointer value <strong>before</strong> I add 'a3'?</p>
  
  <p>I have a simple function that does this but I'd rather not copy the array if I don't have to.</p>
  
  <pre><code>function array_collapse($array) {
      $return = array();
      while ($a = current($array)) {
          $return[] = $a;
          next($array);
      }
      return $return;
  }
  </code></pre>