Php Programming Code Examples
Php > Arrays Code Examples
This is a simple select element with month notations. You can translate
This is a simple select element with month notations. You can translate
the names for local using. Based on the current date the actual month is selected.
<?php
$curr_month = date("m");
$month = array (1=>"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$select = "<select name=\"month\">\n";
foreach ($month as $key => $val) {
$select .= "\t<option val=\"".$key."\"";
if ($key == $curr_month) {
$select .= " selected>".$val."\n";
} else {
$select .= ">".$val."\n";
}
}
$select .= "</select>";
echo $select;
?>