InfiniteIterator::__construct

(PHP 5 >= 5.1.0, PHP 7)
Constructs an InfiniteIterator
public InfiniteIterator::__construct ( Iterator $iterator )

Constructs an InfiniteIterator from an Iterator.

Parameters:
iterator

The iterator to infinitely iterate over.

Returns:

No value is returned.

Exception:

Throws an E_RECOVERABLE_ERROR if the iterator parameter is not an Iterator.

Examples:
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() -

doc_php
2016-02-24 16:19:55
Comments
Leave a Comment

Please login to continue.