sjrsmile
9/6/2017 - 3:04 PM

find first and last in array()

find first and last in array()

<?php
$len = count($array);
foreach ($array as $index => $item) {
    if ($index == 0) {
        // first
    } else if ($index == $len - 1) {
        // last
    }
}
?>