In this example, I will show you how to use the @break
and @continue
statement in the Laravel blade file. We need this @break and @continue in our loop to skip the specific iteration or want to end the loop. So if you don't know how to use them then this example is for you.
Let's see the example of @break and @continue in @foreach() loop in Laravel:
@foreach ($users as $user)
@if ($user->type == 1)
@continue
@endif
<li>{{ $user->name }}</li>
@if ($user->number == 5)
@break
@endif
@endforeach
Read also: Laravel 9 All Blade Template Loop Example
Hope it can help you.