My array :
$arr = array(\"jan\",\"feb\",\"mar\",\"apr\",\"mei\",\"jun\",\"jul\",\"agu\",\"sep\",\"okt\",\"nov\",\"des\");
then i do a foreach<
foreach ($arr as $key => $ar) {
//check we aren't on jan (otherwise we get $key = -1 which doesn't work)
if ($key != 0) {
//print previous month followed by current month
echo $arr[$key - 1] . '-' . $ar . '
';
}
}
//OR, if you want to be able to roll through years then:
$last_key = end(array_keys($arr));
foreach ($arr as $key => $ar) {
//check we aren't on jan
if ($key != 0) {
//print previous month followed by current month
echo $arr[$key - 1] . ' - ' . $ar . '
';
} else {
echo $arr[$last_key] . ' - ' . $ar . '
';
}
}