Skip to content

Instantly share code, notes, and snippets.

@lenivene
Created March 15, 2016 18:34
Show Gist options
  • Save lenivene/4d91e9d9f43d219674fa to your computer and use it in GitHub Desktop.
Save lenivene/4d91e9d9f43d219674fa to your computer and use it in GitHub Desktop.
Generate listing of years
<select name="year">
<?php
$max_years = 100;
for ( $id = 1, $year = date('Y'); $year > ( date('Y') - $max_years ); $year-- ) {
if( date('Y') - 2 == $year ){
?>
<option selected>Selecione o Ano</option>
<?php } ?>
<option value="<?php echo $year; ?>" id="<?php echo $id; ?>"><?php echo $year; ?></option>
<?php $id++;} ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment