busnut Posted March 8, 2009 Share Posted March 8, 2009 G'day I've got this bit below where users can select the month & year of their choice, but I can't seem to work out how to get it to display the full month name. the value of the search needs to be in the 3 letter format (ie, Jan, Feb, Mar etc etc), but what the users see in the dropdown box needs to be 'January', 'February', 'March' etc etc. <Select NAME="month"> <?php echo "<option value=".date(M).">".date(F)."</option>"; echo "<option>-----</option>"; $arr = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); foreach ($arr as $value) { echo "<Option VALUE=$value>$value</option>"; } ?> <Option VALUE="">All Year</option> </Select> It works for the first month that is displayed (which is the current month), but i've tried with failing getting it to display in the same format for the 12 months listed. Any help appreciated! Link to comment https://forums.phpfreaks.com/topic/148450-solved-populate-short-month-to-long-month-name/ Share on other sites More sharing options...
ratcateme Posted March 8, 2009 Share Posted March 8, 2009 $arr = array('Jan' => 'January', 'Feb' => 'February'); //you need to complete this foreach ($arr as $code => $full) { echo "<Option VALUE=$code>$full</option>"; } Scott. Link to comment https://forums.phpfreaks.com/topic/148450-solved-populate-short-month-to-long-month-name/#findComment-779396 Share on other sites More sharing options...
busnut Posted March 8, 2009 Author Share Posted March 8, 2009 Something so simple, I had tried that =>'fullmonth' in the arr line, but not down in the foreach line' Thankyou very much, most appreciated! Link to comment https://forums.phpfreaks.com/topic/148450-solved-populate-short-month-to-long-month-name/#findComment-779411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.