title: Calculate maximum week number in PHP
body: <p>I am searching for a way to calculate the maximum week number for a given year in PHP. Since the last week number of a year is defined by whichever week has the first Thursday in the new year, I am not really sure how to do it.</p>
  
  <pre class="lang-php prettyprint-override"><code>date('W', strtotime( $year.'-12-31 23:59:59'));
  </code></pre>
  
  <p>could also already return <code>1</code>, if the 31st of December is a Monday, Tuesday or Wednesday. So I was thinking, maybe do it like this?</p>
  
  <pre><code>date('N', strtotime( $year.'-12-31 23:59:59')) &lt;= 3 ? 52 : 53;
  </code></pre>
  
  <p>i.e., checking if the last day of the year is a Monday, Tuesday or Wednesday and if so, it's 52 week year, otherwise a 53 week year. Not sure if that's the correct way.</p>