Home >>PHP Programs >How to Print January to December using PHP

How to Print January to December using PHP

How to print January to December using PHP display in drop down

<?php
$month_names = array("January","February","March","April","May","June","July","August","September","October","November","December");
echo "<select>";

foreach($month_names as $month)
{
echo "<option>".$month."</option>";
}
echo "</select>";
?>

Another way to display the Month name in drop-down

<?php
<select>
<?php
$month_names = array("January","February","March","April","May","June","July","August","September","October","November","December");
foreach($month_names as $month)
{
?>
<option value="<?php echo $month; ?>"><?php echo $month; ?></option>
<?php 
}
?>
</select>
?>

Display the Months name using your function

<?php
function showMonthNames($month_names)
 {
	foreach($month_names as $month)
	{
	echo $month."<br/>";
	}
 
 }
showMonthNames($month_names);
?>

No Sidebar ads