title: Get all weeks up to current week / year
body: <p>I have the following code, which gets all 52 past weeks up until the current week.  I want to amend it so that it only includes the current year.  So it should only show the first 4 weeks of January.</p>
  
  <pre><code>public static function weeks()
  {
      $nextWeek = strtotime('+1 week');
  
      for($i=0;$i&lt;52;$i++) 
      {
          $date   = date('Y-m-d', strtotime('-'.$i.' week'));
          $nbDay  = date('N', strtotime($date));
          $monday = new \DateTime($date);
          $sunday = new \DateTime($date);
          $monday-&gt;modify('-'.($nbDay-1).' days');
          $sunday-&gt;modify('+'.(7-$nbDay).' days');
  
          if($nextWeek &gt; strtotime($sunday-&gt;format('Y-m-d'))) {
              $weeks[$monday-&gt;format('W')] = $monday-&gt;format('j M Y') . ' - ' . $sunday-&gt;format('j M Y');
          }
      }
  
      return $weeks;
  }
  </code></pre>
  
  <p>How can I amend the code?</p>