only have 10 items?
implement a counter and increment on each loop, break after 10?
If the foreach is in blade then a $loop counter is implemented for you
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How do I break a foreach loop after 10 times of iterations?
@j_watson so much easier with code
option 1
@foreach($list->take(10) as $contestant)
<p>{{ $contestant->name }}</p>
@endforeach
note that this does not affect your $list it will still contain 20 items
option 2
@foreach($list as $contestant)
@if($loop->index==10)
@break
@endif
<p>{{ $contestant->name }}</p>
@endforeach
obviously not as pretty and requires testing the counter on each loop
option 3, you are doing this because you want to split 20 into two blocks of 10
@php($groups = $list->split(2))
@foreach($groups[0] as $contestant)
<p>{{ $contestant->name }}</p>
@endforeach
@foreach($groups[1] as $contestant)
<p>{{ $contestant->name }}</p>
@endforeach
Please or to participate in this conversation.