Reputation: 75
Please can someone tell me what I am doing wrong here because it is giving me a blank result. just a newbie wanting to learn.
$months = "2";
$month = array(1=>January,"2"=>February,"3"=>March,"4"=>April,"5"=>May,"6"=>June,"7"=>July,"8"=>August,"9"=>September,"10"=>October,"11"=>November,"12"=>December);
$description = 'In respect of '.$particular.' collection for the month of ';print $month['$months'];
echo $description
Upvotes: 0
Views: 318
Reputation: 4652
You haven't enclosed the array string values in quotes. Change your $month definition to this:
$month = array(
1 => "January",
2 => "February",
3 => "March",
4 => "April",
5 => "May",
6 => "June",
7 => "July",
8 => "August",
9 => "September",
10 => "October",
11 => "November",
12 => "December"
);
Also, you don't really need to create an associative array for the month names. You can get a month's name from its number like this:
$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
Upvotes: 1