第2个回答 推荐于2017-09-01
第一种:
$nextdate = ‘’;
for($i=0;$i<12;$i++){
$nextdate .= date("Y-m",strtotime("- $i month")).'<br />';
}
echo $nextdate;
第二种,用数组。
如:
$nextdate = array();
for($i=0;$i<12;$i++){
$nextdate[] = date("Y-m",strtotime("- $i month"));
}
然后用 foreach 遍历 $nextdate