Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


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; ?>