NoRewindIterator
PHP Manual

NoRewindIterator::__construct

(PHP 5 >= 5.1.0)

NoRewindIterator::__constructConstruct a NoRewindIterator

Açıklama

public NoRewindIterator::__construct ( Iterator $iterator )

Constructs a NoRewindIterator.

Değiştirgeler

iterator

The iterator being used.

Dönen Değerler

A NoRewindIterator() based on the passed in iterator.

Örnekler

Örnek 1 NoRewindIterator::__construct() example

The second loop does not output because the iterator is only used once, as it does not rewind.

<?php
$fruit 
= array('apple''banana''cranberry');

$arr = new ArrayObject($fruit);
$it  = new NoRewindIterator($arr->getIterator());

echo 
"Fruit A:\n";
foreach( 
$it as $item ) {
    echo 
$item "\n";
}

echo 
"Fruit B:\n";
foreach( 
$it as $item ) {
    echo 
$item "\n";
}
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

Fruit A:
apple
banana
cranberry
Fruit B:

Ayrıca Bakınız


NoRewindIterator
PHP Manual