<?php

$data = array('Mela', 'Pera', 'Kiwi');
$iterator = new NoRewindIterator(new ArrayIterator($data));
echo $iterator->current(), PHP_EOL;
$iterator->next();
echo $iterator->current(), PHP_EOL;
$iterator->next();
echo $iterator->current(), PHP_EOL;
$iterator->rewind();
echo $iterator->current(), PHP_EOL;
Exemplo n.º 2
0
<?php

echo "===Current===\n";
$it = new NoRewindIterator(new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C')));
echo $it->key() . '=>' . $it->current() . "\n";
echo "===Next===\n";
$it->next();
echo "===Foreach===\n";
foreach ($it as $key => $val) {
    echo "{$key}=>{$val}\n";
}
?>
===DONE===
<?php 
exit(0);
Exemplo n.º 3
0
 function next()
 {
     echo __METHOD__ . "\n";
     parent::next();
 }