<?php
$fruits = new ArrayIterator(array(
'apple',
'banana',
'cherry',
'orange',
'pear'
));
// Passing by the custom iterator only a substet of the elements
foreach (new ArrayIterator(new LimitIterator($fruits , 2, 2)) as $fruit) {
var_dump($fruit);
}