I need to assign a variable to be the output of a function that contains a loop.
Current function:
function dateRange($numberofDays){
while($x<=$numberofDays) {
$currentNumber = "-" . $x . " days";
$date = DATE('Y-m-d', STRTOTIME($currentNumber));
$theRange = $date . ",";
$x++;
}
return $theRange;
}
Current result:
echo dateRange(7); // outputs a single date "2014-08-02,"
I need to return a string of dates, however it only seems to be pulling the LAST date in the function.
Looking for something like: "2014-08-08,2014-08-07,2014-08-06,2014-08-05,2014-08-04,"
$theRangevalue. What would be required to keep adding onto the existing value until the loop is complete?