- iterator_apply: documentation ( source)
- ucfirst: documentation ( source)
<?php
$ll = new SplDoublyLinkedList();
$ll->push('one');
$ll->push('two');
$ll->push('three');
$ll->push('four');
$ll->rewind();
$iterations_done = iterator_apply($ll, function(Iterator $it) {
echo $it->key(),"\t->", $it->current(),"\t->", ucfirst($it->current()),".\n";
$it->next();
return true;
}, array($ll));
echo "Did iterate {$iterations_done} times \n";