title: Function with loop only returns last value
body: <p>I need to assign a variable to be the output of a function that contains a loop.</p>
  
  <p>Current function:</p>
  
  <pre><code>function dateRange($numberofDays){
      while($x&lt;=$numberofDays) {
          $currentNumber = "-" . $x . " days";
          $date = DATE('Y-m-d', STRTOTIME($currentNumber));
          $theRange = $date . ",";
          $x++;
      }
      return $theRange;
  }
  </code></pre>
  
  <p>Current result:</p>
  
  <pre><code>echo dateRange(7); // outputs a single date "2014-08-02,"
  </code></pre>
  
  <p>I need to return a string of dates, however it only seems to be pulling the LAST date in the function.</p>
  
  <p>Looking for something like: "2014-08-08,2014-08-07,2014-08-06,2014-08-05,2014-08-04,"</p>