我有一个这样的循环:
@foreach($data as $d)
@if(condition==true)
{{$d}}
// Here I want to break the loop in above condition true.
@endif
@endforeach
如果条件满足,我想在数据显示后中断循环.
如何在laravelBlade 视图中实现?
我有一个这样的循环:
@foreach($data as $d)
@if(condition==true)
{{$d}}
// Here I want to break the loop in above condition true.
@endif
@endforeach
如果条件满足,我想在数据显示后中断循环.
如何在laravelBlade 视图中实现?
From the Blade docs:
When using loops you may also end the loop or skip the current iteration:
@foreach ($users as $user)
@if ($user->type == 1)
@continue
@endif
<li>{{ $user->name }}</li>
@if ($user->number == 5)
@break
@endif
@endforeach