请有人告诉我这里我做错了什么,因为它给了我一个空白的结果。只是一个想要学习的新手。
$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
答案 0 :(得分: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));