Wondering what would be a good method to get the first iteration on a foreach loop. I want to do something different on the first iteration.
Is a conditional our b
foreach($array as $element) { if ($element === reset($array)) echo 'FIRST ELEMENT!'; if ($element === end($array)) echo 'LAST ELEMENT!'; }