RsD0p9BK
10/5/2015 - 5:57 AM

Last_in_array.php

// How to determine the first and last iteration in a foreach loop? 
// stackoverflow.com/questions/1070244/how-to-determine-the-first-and-last-iteration-in-a-foreach-loop

reset($array);
$first = key($array);
foreach($array as $key => $element) {
    if ($key === $first)
        echo 'FIRST ELEMENT!';
}