Iterator

An iterator is an object which can be traversed with a foreach() loop.

Iterator is an interface, which shall be implemented by objects. There are also a list of default iterators in the SPL extension.

An iterator may be turned into an array, with the iterator_to_array() function.

<?php

class myIterator implements Iterator { /**/ }

$it = new myIterator;

foreach($it as $key => $value) {
    var_dump($key, $value);
    echo "\n";
}

?>

Documentation

See also Modern PHP Developer - Iterator, Iterator in PHP

Related : Standard PHP Library (SPL), Traversal, Foreach