(PHP 5 >= 5.1.0, PHP 7, PHP 8)
InfiniteIterator::__construct — Constructs an InfiniteIterator
Constructs an InfiniteIterator from an Iterator.
iterator
The iterator to infinitely iterate over.
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";
}
?>
Il precedente esempio visualizzerĂ :
cat dog cat dog cat dog cat