©
本文档使用 PHP中文网手册 发布
(PHP 5 >= 5.1.0)
InfiniteIterator::__construct — Constructs an InfiniteIterator
$iterator
)Constructs an InfiniteIterator from an Iterator.
iterator
The iterator to infinitely iterate over.
没有返回值。
Throws an E_RECOVERABLE_ERROR
if the
iterator
parameter is not
an Iterator.
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" ;
}
?>
以上例程会输出:
cat dog cat dog cat dog cat