CachingIterator::hasNext Example
<?php
$ait = new ArrayIterator(array('Value 1', 'Value 2', 'Value 3', 'Value 4'));
$cit = new CachingIterator($ait);
foreach ($cit as $value) {
echo $value;
//if has a next value, print a comma
if ($cit->hasNext()) {
echo ', ';
}
}
?>
Result: Value 1, Value 2, Value 3, Value 4