title: php generate a select box having dropdown years of -5 years and +5 years
body: <p>I want to generate a select box drop down list having date ranges of -3 years and +5 years dynamically using PHP.</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;select name="years"&gt;
      &lt;option value="2016"&gt;2016&lt;/option&gt;
      &lt;option value="2017"&gt;2017&lt;/option&gt;
      &lt;option value="2018"&gt;2018&lt;/option&gt;
      &lt;option value="2019"&gt;2019&lt;/option&gt; // Current Year
      &lt;option value="2020"&gt;2020&lt;/option&gt;
      &lt;option value="2021"&gt;2021&lt;/option&gt;
      &lt;option value="2022"&gt;2022&lt;/option&gt;
      &lt;option value="2023"&gt;2023&lt;/option&gt;
      &lt;option value="2024"&gt;2024&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Something like this. And each year the list will automatically get updated like in 2020 the min range will become 2017 and max range will become 2025. How to do this? Any help will be appreciated.</p>