Wednesday, 24 September 2014

Display days and months in year PHP



<?php
//without using key
$days = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
//using key
$month = array("[jan]"=>"January","[feb]"=>"February","[mar]"=>"March","[apr]"=>"April",
" [may]"=>"May","[jun]"=>"June","[jul]"=>"July","[aug]"=>"August","[sep]"=>"September",
"[oct]"=>"October"," [nov]"=>"November","[dec]"=>"December");


$month_without_keys = array("January","February","March","April","May","June","July","August","September","October","November","December");


echo "Days are :";
print_r($days);
echo "<br>";
echo "Months are :";
print_r($month);

echo "<br>Months Without Keys: ";
print_r($month_without_keys);
?>

output:
Days are :
 Array ( 
            [0] => Sunday 
            [1] => Monday
            [2] => Tuesday 
            [3] => Wednesday
            [4] => Thursday
            [5] => Friday 
            [6] => Saturday
         )
Months are : 
Array ( 
          [jan] => January
          [feb] => February 
          [mar] => March 
          [apr] => April 
          [may] => May 
          [jun] => June 
          [jul] => July
          [aug] => August 
          [sep] => September
          [oct] => October
          [nov] => November 
          [dec] => December
        )

Months Without keys : 
Array ( 
          0 => January
          1 => February 
          2 => March 
          3 => April 
          4 => May 
          5 => June 
          6 => July
          7 => August 
          8 => September
          9 => October
          10 => November 
          11 => December
        )

0 comments:

Post a Comment