I have a <sel开发者_Python百科ect> dropdown with which I want to populate the previous 20 years as well as the current year. How would I go about this?
It would be simpler to use strtotime()
echo strtotime("+1 year");
You can also use this inside a loop
echo strtotime("+".$i." year");
Where $i is the index in the loop.
This should be all you need:
echo "<select>";
for ($i = date("Y") - 20; $i <= date("Y"); $i++)
{
    echo "<option value='{$i}'>{$i}</option>";
}
echo "</select>";
What about trying something like this:
for (i=0;i<20;i++) {
    echo mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+i);
}
Seems like you just need a snippet like this:
$current_year = date("Y");
$min_year = 1990;
echo '<select name="year">';
echo '<option value="">Select Year..</option>";
for($i=$min_year; $i<=$current_year; $i++) {
echo '<option value="'.$i.'">'.$i.'</option>';
}
echo '</select>';
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论