我在一個正在製作日期的while循環中有一個變量。我希望將while循環的每次迭代中生成的所有日期轉換爲while循環外的數組。這可能嗎?如何使while循環中的迭代值數組超出
while($row=mysql_fetch_array($sq))
{
extract($row);
$startDate = date("d-m-Y", strtotime($created_on. ' + '.$days_for_start.' days'));
$end_date = date("d-m-Y", strtotime($created_on. ' + '.$days_for_end.' days'));
}
print_r($end_date);
//should output, 24-03-2017 for number of times the loop is running, in an array.
inside'while' loop use this'$ end_date [] = ...' –
使用數組例如'$ end_dates = [];'循環前和'$ end_dates [] =日期...'循環內然後'print_r($ end_dates)'外循環 – apokryfos
對不起,沒有成功:(@SahilGulati – Ansh