Loop collection range

Hello there, Is it possibile to specify a range value for loop?
For example I need to grab all the pages from 5 to 10, thus excluding the range from 1 to 4.

I was looking this recipe:

// only get the first three items
$items = $page->children()->listed()->limit(3)

// or get the first and then the rest
$items = $page->children()->listed();
$firstItem = $items->first();
$allOtherItems = $items->offset(1); // all but the first item

slice() is your best option I guess:

For your example:

$items = $page->children()->listed()->slice(4,6);
1 Like