title: Next Iterator method for associative Array
body: <p>I want to use an associative array with the PHP iterator:</p>
  
  <p><a href="http://php.net/manual/en/class.iterator.php" rel="noreferrer">http://php.net/manual/en/class.iterator.php</a></p>
  
  <p>is it possible?</p>
  
  <p>I defined these methods:</p>
  
  <pre><code>  public function rewind(){    
      reset($this-&gt;_arr);
      $this-&gt;_position = key($this-&gt;_arr);
    }
  
    public function current(){    
      return $this-&gt;_arr[$this-&gt;_position];
    }
  
    public function key(){
      return $this-&gt;_position;
    }
  
    public function next(){    
      ++$this-&gt;_position;
    }
  
    public function valid(){    
      return isset($this-&gt;_arr[$this-&gt;_position]);
    }
  </code></pre>
  
  <p>the problem is it doesn't iterate correctly. I only get one element.</p>
  
  <p>I think it's because of the <code>++$this-&gt;_position</code> code in the next() method which doesn't have any effect because _position is a string (key of the associative array).</p>
  
  <p>so how can I go to the next element of this type of array?</p>