0

请有人告诉我我在这里做错了什么,因为它给了我一个空白的结果。只是一个想学习的新手。

$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
4

1 回答 1

1

您没有将数组字符串值括在引号中。将您的 $month 定义更改为:

$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"
);

此外,您实际上并不需要为月份名称创建关联数组。您可以从它的数字中获取一个月的名称,如下所示:

$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
于 2013-06-09T03:43:26.747 回答