Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how get the first item in foreach in laravel

@foreach($items as $item)
    @if ($loop->first) First Item: @endif
    <h4>{{ $item->program_name }}</h4>
@endforeach
Comment

laravel foreach first

@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
Comment

PREVIOUS NEXT
Code Example
Php :: laravel datatable format date column 
Php :: php remove array element reset keys 
Php :: php in html attributes 
Php :: error in laravel 
Php :: how to change date formate in laravel 
Php :: Excerpt/ get post content 
Php :: How to get a WordPress post by slug 
Php :: startsWith() and endsWith() functions in PHP 
Php :: laravel eloquent select one column 
Php :: get current month records in laravel 
Php :: add hour minute in datetime in php 
Php :: php pdo update 
Php :: php array to string 
Php :: print array items in php 
Php :: how to convert array to string in php 
Php :: use auth automatic login on register 
Php :: php zeilenumbruch 
Php :: php date first day of month and last month 
Php :: file put contents append 
Php :: laravel model query limit 
Php :: get id php 
Php :: difference entre deux date php 
Php :: drupal load all nodes of type 
Php :: public_path laravel 
Php :: how add new column in larevel with migration 
Php :: Syntax error or access violation: 1071 Specified key was too long; 
Php :: convert all text in php to uppercase 
Php :: fnmatch php ignore case 
Php :: define constant in php 
Php :: php replace string within string 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =