<?php $lookup = array_flip(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']); $months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Sep', 'Oct', 'Dec']; $result = []; foreach ($months as $month) { if (isset($ref) && $lookup[$month] === $lookup[$last] + 1) { $ref = strtok($ref, "-") . "-$month"; } else { unset($ref); $ref = $month; $result[] = &$ref; } $last = $month; } var_export($result);
You have javascript disabled. You will not be able to edit any code.