list of Months

From: Date: Thu, 30 Sep 2004 20:16:46 +0000
Subject: list of Months
Groups: php.general 
Request: Send a blank email to php-general+get-198339@lists.php.net to get a copy of this message
Hi, to create a list of all months in drop-down menu I use this code: <?php $month_names = array(1=>'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); ?> <select name="QuoteMonth"> <option value=""></option> <?php for($i=1; $i<=12; $i++) { if(date('m') == $i) $selected_QuoteMonth = 'SELECTED'; else $selected_QuoteMonth = ''; echo "<option value=$i $selected_QuoteMonth> $i </option>"; } ?> </select> Is there any better way? Thanks for any help. Afan

« previous php.general (#198339) next »