需要对此进行填充: str_pad($Month, 2, "0", STR_PAD_LEFT) 但是如何/在哪里???
/*******creates the month selection dropdown array****/
function createMonths($id='month_select', $selected=null)
{
/*** array of months ***/
$months = array(
1=>'Jan',
2=>'Feb',
3=>'Mar',
4=>'Apr',
5=>'May',
6=>'Jun',
7=>'Jul',
8=>'Aug',
9=>'Sep',
10=>'Oct',
11=>'Nov',
12=>'Dec');
/*** current month ***/
$selected = is_null($selected) ? date('m') : $selected;
$select = '<select name="'.$id.'" id="'.$id.'">'."\n";
foreach($months as $key=>$mon)
{
$select .= "<option value=\"$key\"";
$select .= ($key==$selected) ? ' selected="selected"' : '';
$select .= ">$mon</option>\n";
}
$select .= '</select>';
return $select;
}
/********displays the month selection with current month selected/*******</br>
echo createMonths('Month', date ('m'));
/******DISPLAYS MONTH AS (4) INSTEAD OF REQUIRED (O4) --- @:( /*****</br>
echo $_POST['Month'];