= 5.1.0, PHP 7, PHP 8)InfiniteIterator::__construct — Constructs an InfiniteIterator說(shuō)明public InfiniteIterator::__">

InfiniteIterator::__construct

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

InfiniteIterator::__constructConstructs an InfiniteIterator

說(shuō)明

public InfiniteIterator::__construct(Iterator $iterator)

Constructs an InfiniteIterator from an Iterator.

參數(shù)

iterator

The iterator to infinitely iterate over.

范例

示例 #1 InfiniteIterator::__construct() example

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

以上例程會(huì)輸出:

cat
dog
cat
dog
cat
dog
cat

參見(jiàn)