How do I create a selected
attribute only in the current year in the <select>
that I have below? As we are in 2018, <option>
selected should be 2018.
<select>
<?php
$ano_atual = date("Y");
for($i = 2014; $i <= $ano_atual; $i++) {
echo "<option value=\"$i\">$i</option>\n";
}
?>
</select>