- print_r: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
function _getRollingMonths($months = 12) {
$dates = array();
for($i=$months-1;$i>=0;$i--) {
$dates[] = array(
'year' => date('Y', strtotime("-$i months")),
'month' => date('m', strtotime("-$i months")),
'monthName' => date('M', strtotime("-$i months"))
);
}
return $dates;
}
function debug($var) {
echo "<pre>";
print_r($var);
echo "</pre>";
}
debug(_getRollingMonths(3));