“Variabel Laravel Loop” Kode Jawaban

Variabel loop di Laravel

Property			Description
$loop->index		The index of the current loop iteration (starts at 0).
$loop->iteration	The current loop iteration (starts at 1).
$loop->remaining	The iterations remaining in the loop.
$loop->count		The total number of items in the array being iterated.
$loop->first		Whether this is the first iteration through the loop.
$loop->last			Whether this is the last iteration through the loop.
$loop->even			Whether this is an even iteration through the loop.
$loop->odd			Whether this is an odd iteration through the loop.
$loop->depth		The nesting level of the current loop.
$loop->parent		When in a nested loop, the parent's loop variable.
Clean Cowfish

Cara Menulis untuk Loop di Laravel Blade

<div>
    @for ($i = 0; $i < $max; $i++) //Where $max is whatever you need as break condition.
        <p>{{ $i }}</p> //This would print $i in a paragraph. You do whatever you need here.
    @endfor
</div>
NachooCh

Variabel Laravel Loop

@foreach ($users as $user)
    @if ($loop->first)
        This is the first iteration.
    @endif

    @if ($loop->last)
        This is the last iteration.
    @endif

    <p>This is user {{ $user->id }}</p>
@endforeach
Fernando Gunther

Jawaban yang mirip dengan “Variabel Laravel Loop”

Pertanyaan yang mirip dengan “Variabel Laravel Loop”

Lebih banyak jawaban terkait untuk “Variabel Laravel Loop” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya