title: PHP Weekly date range with specific start and end day
body: <p>Hi I already have a date range result but how can I make the date range start at every Thursday and ends at Wednesday. Thanks for your help :)</p>
  
  <p>
  
  <pre><code>$week_range = '';
  for ($i = 0; $i &lt;= 4; $i++) {
      $k = $i - 1;
  
      $ymd_week_range = date('Y-m-d', strtotime("-$i week")) . ',' . date('Y-m-d', strtotime("-$k week -1 day"));
  
      $day_from = date('j', strtotime("-$i week"));
      $day_to = date('j', strtotime("-$k week -1 day"));
      $month_to = date('M', strtotime("-$i week"));
      $month_from = date('M', strtotime("-$k week -1 day"));
      $year_to = date('Y', strtotime("-$i week"));
      $year_from = date('Y', strtotime("-$k week -1 day"));
  
      $weeks[$ymd_week_range] = "$month_from $day_from-$day_to, $year_to";   
  }
  
  
  
  Array
      (
          [2017-03-16,2017-03-22] =&gt; Mar 16-22, 2017
          [2017-03-09,2017-03-15] =&gt; Mar 9-15, 2017
          [2017-03-02,2017-03-08] =&gt; Mar 2-8, 2017
          [2017-02-23,2017-03-01] =&gt; Mar 23-1, 2017
          [2017-02-16,2017-02-22] =&gt; Feb 16-22, 2017
      )
  </code></pre>
  
  <p>So today is thursday so it is correct. But if today is friday then the result is wrong. If today is friday then I want the correct result above. The wrong result is: </p>
  
  <pre><code>Array
          (
              [2017-03-17,2017-03-23] =&gt; Mar 17-23, 2017
              [2017-03-10,2017-03-16] =&gt; Mar 10-16, 2017
              [2017-03-03,2017-03-09] =&gt; Mar 3-9, 2017
              [2017-02-24,2017-03-02] =&gt; Mar 24-2, 2017
              [2017-02-17,2017-02-23] =&gt; Feb 17-23, 2017
          )
  </code></pre>