phpday 2027 - Call for Papers

InfiniteIterator::__construct

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

InfiniteIterator::__construct — Constructs an InfiniteIterator

Опис

public function InfiniteIterator::__construct(Iterator $iterator)

Constructs an InfiniteIterator from an Iterator.

Параметри

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($infinite, 0, 7);
foreach($limit as $value)
{
    echo "$value\n";
}
?>

Поданий вище приклад виведе:

cat
dog
cat
dog
cat
dog
cat

Прогляньте також

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top