Answers for "laravel looping checking if last record has reached"

PHP
0

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++;
}
Posted by: Guest on June-28-2021

Code answers related to "laravel looping checking if last record has reached"

Browse Popular Code Answers by Language