Re: drop down list of years puzzles me

From: Date: Tue, 20 Jan 2004 23:17:43 +0000
Subject: Re: drop down list of years puzzles me
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175235@lists.php.net to get a copy of this message
On Wednesday, January 21, 2004, at 10:10 AM, Bill Green wrote:
This doesn't to create a drop down box of years: $curr_year = intval(date('Y')); $range = 10; for ($y=$curr_year; $y < $range; $y++) {
     echo "<option value={$y}>".$y."</option>\n";
}
Stop and read the for loop. You're saying "starting with the current year, increment, as long as the range is less than *10*." Unless you have a time machine, the year will always be greater than "10" :P $y = intval(date('Y')); $range = $y + 10; for ($y < $range) {
    echo "<option value='{$y}'>{$y}</option>\n";
$y++; } Justin French

« previous php.general (#175235) next »