Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel looping checking if last record has reached

$count = 0;
$len = count($array);
foreach ($array as $item) {
    if ($count == 0) {
        // first
    } else if ($count == $len - 1) {
        // last
    }
    // increment
    $count++;
}
 
PREVIOUS NEXT
Tagged: #laravel #looping #checking #record #reached
ADD COMMENT
Topic
Name
6+7 =