SPL's LimitIterator , a simple example
$numbers = array(22, 60, 876, 95, 77);
// Initializing the Iterator
$iterator = new ArrayIterator($numbers);
// Pass the converted array to the LimitIterator
$limiter = new LimitIterator($iterator, 0 , 4);
// Loop through the LimitIterator object
foreach ($limiter as $number) {
echo $number . '<br />';
}