我有像
这样的月份数组$month = array(
01 => "January",
02 => "February",
03 => "March",
04 => "April",
05 => "May",
06 => "June",
07 => "July",
08 => "August",
09 => "September",
10 => "October",
11 => "Novemeber",
12 => "December"
);
但是当我打印它时,它显示如下<
Array
(
[1] => January
[2] => February
[3] => March
[4] => April
[5] => May
[6] => June
[7] => July
[0] => September
[10] => October
[11] => Novemeber
[12] => December
)
它显示为9月和8月不是显示。
任何人都可以告诉我这有什么问题。
感谢
答案 0 :(得分:4)
尝试添加引号:
$month = array(
"01" => "January",
"02" => "February",
"03" => "March",
"04" => "April",
"05" => "May",
"06" => "June",
"07" => "July",
"08" => "August",
"09" => "September",
"10" => "October",
"11" => "Novemeber",
"12" => "December"
);
答案 1 :(得分:1)
从0开始的Nubmber被解释为octal constats。
由于8
和9
不是八进制中的有效数字,08
和09
是无效数字,并且都被解释为0
。 “08”是字符串,即使在算术运算的情况下,也会被解释为正常的十进制整数:
"echo '08'+'08'; // 16
因此,使用字符串应该是安全的。