Search
 
SCRIPT & CODE EXAMPLE
 

PHP

loop variable in 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.
Comment

laravel loop variable

@foreach($listdata as $data)
	// normal iteration
		{{ $data->iteration() }}

	// if you using "paginate()" in your query, better use this iteration per-page below:
		// for example:
			// page 1 iteration = 1,2,3,4,5 ascending, 5,4,3,2,1 descending
			// and page 2 iteration will be = 6,7,8,9,10 ascending, 10,9,8,7,6 descending

        // iteration ascending (1,2,3,...)
            {{ $data->firstItem() + $loop->index }}

        // iteration descending (...,3,2,1)
            {{ ($data->total()-$loop->index) - (($data->currentpage()-1) * $data->perpage()) }}
@endforeach
Comment

PREVIOUS NEXT
Code Example
Php :: convert stdclass to json in php 
Php :: how to check php string length 
Php :: php median 
Php :: xampp check php version 
Php :: transaction cakephp 2 
Php :: update user meta wp code 
Php :: php sleep 1 second 
Php :: Error: Call to a member function getClientOriginalName() on null in file /usr/local/var/www/murabaha_backend/app/Http/Controllers/Traits/MediaUploadingTrait.php 
Php :: php counting number of chars excluding newlines 
Php :: destroy php variable 
Php :: Cannot use object of type stdClass as array 
Php :: InvalidArgumentException Unknown format "sentence" 
Php :: incorrect format parameter phpmyadmin xampp 
Php :: phpmailer for wordpress 
Php :: wordpress display post comment number 
Php :: php header excel utf-8 
Php :: laravel route is current route 
Php :: get the last inserted id using laravel eloquent 
Php :: php str_replace multiple 
Php :: email php using html 
Php :: laravel descending order paginate eloquent 
Php :: laravel when 
Php :: wp_trim_words 
Php :: php convert number to month 
Php :: to stop XAMPP ubuntu 
Php :: image exists in laravel 
Php :: php datetime to timestamp 
Php :: php loop backwards through array 
Php :: php see if undefined 
Php :: show selected value in dropdown laravel 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =