3
什么是最有效的方法来获取从指定的日期,直到现在的一个月的数组,按年分组。最有效的方法来获得年数阵列
如getMonths( “2012年8月”)将输出
array(
array("Year"=>"2013", "months" = array(
"February", "January")
),
array("Year"=>"2012", "months" = array(
"December", "November","October", "September", "August")
)
)
到目前为止我有:
$start = strtotime('2012-08-01');
$end = time();
$month = $start;
$months[] = date('F', $start);
while($month <= $end) {
$month = strtotime("+1 month", $month);
$months[] = date('F', $month);
}
这是输出正确个月,但没有将它们组合成年。 感谢
这看起来不错,不错的工作:) – user1477388 2013-02-27 20:44:47
@use r1477388谢谢 – Baba 2013-02-27 20:47:06