Basic usage
By default, blade doesn't have @break
and @continue
which are useful to have. So that's included.
Furthermore, the $loop
variable is introduced inside loops, (almost) exactly like Twig.
Basic Example
@foreach($stuff as $key => $val)
$loop->index; // int, zero based
$loop->index1; // int, starts at 1
$loop->revindex; // int
$loop->revindex1; // int
$loop->first; // bool
$loop->last; // bool
$loop->even; // bool
$loop->odd; // bool
$loop->length; // int
@foreach($other as $name => $age)
$loop->parent->odd;
@foreach($friends as $foo => $bar)
$loop->parent->index;
$loop->parent->parentLoop->index;
@endforeach
@endforeach
@break
@continue
@endforeach
@break
before@endif
– Keitloa