2
I am needing to list in a select the last 10 years. For this, I am doing so:
<select name="AnoInicio" class="form-control">
<option value="">Ano</option>
<?php
for ($anoInicio = date('Y') - 10; $anoInicio < date('Y'); $anoInicio++)
{
echo '<option value="'.$anoInicio.'">'.$anoInicio.'</option>';
}
?>
</select>
It works, but the problem is that it is listing in ascending order, ie from 2008 to 2018.
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
How do I make it countdown list? from 2018 to 2008?
2018
2017
2016
2015
....
The
range
is a more elegant solution. I hadn’t thought of it. :)– fernandosavio