I'm new to PHP Arrays... but I have created an array to get all dates between 2 dates that have been submitted in a form.
See below:
$endDate=$_POST[todate];
$startDate =$_POST[fromdate];
print_r(getDatesFromRange( "$datef", "$dateto" ));
function getDatesFromRange($startDate, $endDate)
{
$return = array($startDate);
$start = $startDate;
$i=1;
if (strtotime($startDate) < strtotime($endDate))
{
while (strtotime($start) < strtotime($endDate))
{
$start = date('Y-m-d', strtotime($startDate.'+'.$i.' days'));
$return[] = $start;
$i++;
}
}
return $return;
}
This results in the below
Array ( [0] => 2016-10-10 [1] => 2016-10-11 [2] => 2016-10-12 [3] => 2016-10-13 [4] => 2016-10-14 [5] => 2016-10-15 [6] => 2016-10-16 [7] => 2016-10-17 [8] => 2016-10-18 [9] => 2016-10-19 )
Is there a way to save each of these dates to a MySQL database using PHP?