downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

NoRewindIterator::current> <NoRewindIterator
[edit] Last updated: Fri, 24 May 2013

view this page in

NoRewindIterator::__construct

(PHP 5 >= 5.1.0)

NoRewindIterator::__constructConstruct a NoRewindIterator

Description

public NoRewindIterator::__construct ( Iterator $iterator )

Constructs a NoRewindIterator.

Parameters

iterator

The iterator being used.

Return Values

A NoRewindIterator() based on the passed in iterator.

Examples

Example #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";
}
?>

The above example will output something similar to:

Fruit A:
apple
banana
cranberry
Fruit B:

See Also



add a note add a note User Contributed Notes NoRewindIterator::__construct - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites