DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Populate Month Dropdown Menu

01.28.2006
| 426 views |
  • submit to reddit
        // description of your code here

$current_month = strftime("%B");
print "<select>\n";
for ($i = 1; $i < 13 && $m = strftime('%B', mktime(0,0,0,$i)); $i++) {
   if ($m == $current_month) {
      print "<option selected='selected'>$m</option>\n";
   } else {
      print "<option>$m</option>\n";
   }
}
print "</select>";