InfiniteIterator::__construct

Constructs an InfiniteIterator

Description

public InfiniteIterator::__construct(Iterator $iterator)

Constructs an InfiniteIterator from an Iterator.

Parameters

iterator

The iterator to infinitely iterate over.

Examples

Example #1 InfiniteIterator::__construct example

<?php
$arrayit  = new ArrayIterator(array('cat','dog'));
$infinite = new InfiniteIterator($arrayit);
$limit    = new LimitIterator($infinite, 0, 7);
foreach($limit as $value)
{
    echo "$value\n";
}
?>

The above example will output:

cat
dog
cat
dog
cat
dog
cat

See Also

  • InfiniteIterator::next