(PHP 5 >= 5.1.0, PHP 7, PHP 8)
InfiniteIterator::__construct — 构造一个 InfiniteIterator
iterator
要无限迭代的迭代器。
示例 #1 InfiniteIterator::__construct() 示例
<?php
$arrayit = new ArrayIterator(array('cat','dog'));
$infinite = new InfiniteIterator($arrayit);
$limit = new LimitIterator($infinite, 0, 7);
foreach($limit as $value)
{
echo "$value\n";
}
?>
上面的示例将输出
cat dog cat dog cat dog cat