indeks pętli laravel foreach
@foreach ($items as $item)
{{ $loop->index }}
@endforeach
D_ACE
@foreach ($items as $item)
{{ $loop->index }}
@endforeach
@foreach ($teams as $key => $team)
{{ str_ordinal($key + 1) }}
@endforeach
//If you are working with a collection you can do something like this:
foreach($collection as $item) {
if($collection->last() == $item) {
// last iteration
}
}
//If you are working with an array (it also works with collections) you can do this:
foreach($array as $item) {
if(end($array) == $item) {
// last iteration
}
}
{{ $loop->index }}