/** * Will get the previous item and loop within the array if applicable * @param array Array to search. * @param currentItem Item to search. * @return * */ public static function get_previous_item($array, $currentItem) { $currentIndex = array_search($currentItem, $array); $previousIndex = ArrayUtils::get_previous_index($array, $currentIndex, true); return $array[$previousIndex]; }