我有以下数组,需要从当前月份向后排序 - 我得到的是 NULL
这是我正在尝试的:
$months = array(
'January' => 0,
'February' => 0,
'March' => 0,
'April' => 0,
'May' => 0,
'June' => 0,
'July ' => 0,
'August' => 0,
'September' => 0,
'October' => 0,
'November' => 0,
'December' => 0,
);
$current = date('F');
$start = array_search($current, $months);
$toshow = array();
$total = 0;
for($i = $start; $total < 12; $i--)
{
if($i == 0)
{
$i = 12;
}
$toshow[] = $months[$i];
$total++;
}
var_dump($toshow);
我得到的结果是:
array(12) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL }