InfiniteIterator::__construct
InfiniteIterator::__construct
(PHP 5 >= 5.1.0, PHP 7)
InfiniteIterator::__construct — Constructs an InfiniteIterator
Description
public InfiniteIterator::__construct ( Iterator $iterator )
Constructs an InfiniteIterator from an Iterator.
Parameters
iterator
The iterator to infinitely iterate over.
Return Values
No value is returned.
Errors/Exceptions
Throws an E_RECOVERABLE_ERROR
if the iterator
parameter is not an Iterator.
Examples
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";
}
?>
The above example will output:
cat
dog
cat
dog
cat
dog
cat
See Also
- InfiniteIterator::next() - Moves the inner Iterator forward or rewinds it
← InfiniteIterator
© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/infiniteiterator.construct.php