title: Loop dates in PHP with different steps
body: <p>i have function, which loop between two different dates, with steps.
  In the case, when step is 1 week, it doesn't work good. For example if $first = 2013-09-01 and $last = 2013-11-18 then the last showed week is 2013-11-11 - 2013-11-17 </p>
  
  <pre><code>function dateRange($first, $last, $step, $format = 'Y-m-d' ) {
      $dates = array();
      $current = strtotime($first);
      $last = strtotime($last);
  
      while( $current &lt;= $last ) 
      {   
          $dates[] = date($format, $current);
          $current = strtotime($step, $current);
      }
  
      return $dates;
  }
  
  foreach(dateRange('2013-09-01', '2013-11-18', '+1 week') as $day)
  {
       echo $day.'&lt;br /&gt;';
  }
  </code></pre>
  
  <p>Can somebody help me how to edit my function?</p>