I want to run a while(or any) loop to output a small list of dates as an array
$start = $day = strtotime("-1 day");
$end = strtotime('+6 day');
while($day < $end)
{
echo date('d-M-Y', $day) .'<br />';
$day = strtotime("+1 day", $day) ;
}
This works fine for printing, but I want to save it as an array (and insert it in a mysql db).
Yes! I don’t know what I’m doing.
to create a array, you need to first initialize it outside your loop (because of variable scoping)
you can then use your dates using either
foreachorwhileforeach approach :
while approach :