Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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
share|improve this question
add comment

1 Answer

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));
share|improve this answer
 
thanks Filippos. –  Charles Okaformbah Jun 9 '13 at 3:54
 
You're welcome :) glad to help –  Filippos Karapetis Jun 9 '13 at 3:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.