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 } } ?>