使用下面的while循環,我得到了echo中的四個日期,這正是我所需要的。PHP將4個日期放在while循環中的數組中
$data = [];
$start = Carbon::createFromDate('2016', '04', '01');
$end = Carbon::createFromDate('2017', '04', '01');
while($start < $end)
{
$data[] = $start;
echo $start;
$start->addMonths('3');
}
輸出:
2016-04-01
2016-07-01
2016-10-01
2017-01-01
但是,當我轉儲$數據[]數組,我只是送四集合,每個集合具有相同的日期:
2017-04-01
我在做什麼錯誤?我只是想把上述四個日期放在一個數組中。
是的,就是這樣,非常感謝在清除了對我來說,不知道:) – Hardist