HH\Vector::getIterator
Returns an iterator that points to beginning of the current Vector
public function getIterator(): KeyedIterator<int, Tv>;
Returns
KeyedIterator<int,
Tv>
- AKeyedIterator
that allows you to traverse the currentVector
.
Examples
This example shows how to get an iterator from a Vector
and how to consume it:
$v = Vector {'red', 'green', 'blue', 'yellow'};
// Get an iterator for the Vector of colors
$iterator = $v->getIterator();
// Print each color using the iterator
while ($iterator->valid()) {
echo $iterator->current()."\n";
$iterator->next();
}