title: reset a pointer for a for-loop in php
body: <p>given the following code</p>
  
  <pre><code>&lt;?php
  $a = array(1,2,3,4,5,6);
  $c=0;
  foreach($a as $v){
      if($v==5&amp;&amp;$c==0){
          $c=1;
          reset($a);
      }
      var_dump($v);
  }
  </code></pre>
  
  <p>How do I reset the pointer so it will print 1,2,3,4,5,1,2,3,4,5,6 ?</p>
  
  <p>I know that in this case I can simply</p>
  
  <pre><code>&lt;?php
  $a = array(1,2,3,4,5,6);
  $c=0;
  for($i=0;$i&lt;count($a);++$i){
      $v = $a[$i];
      if($v==5&amp;&amp;$c==0){
          $c=1;
          $i=-1;  //because of the loop ++$i
      }
      var_dump($v);
  }
  </code></pre>
  
  <p>But I have a much more complex piece of code and the solution is not as simple as rewrite the loop (not numeric keys).</p>
  
  <p>Any PHP guru out there that can help me here ?</p>