我一年寫了所有月份的數組如下:鍵中的字符串變爲整數?
$MNTH["01"] = "January";
$MNTH["02"] = "February";
$MNTH["03"] = "March";
$MNTH["04"] = "April";
$MNTH["05"] = "May";
$MNTH["06"] = "June";
$MNTH["07"] = "July";
$MNTH["08"] = "August";
$MNTH["09"] = "September";
$MNTH["10"] = "October";
$MNTH["11"] = "November";
$MNTH["12"] = "December";
當我做一個變量轉儲上的$MNTH
鍵與var_dump(array_keys($MNTH))
, 我得到:
array(12) {
[0]=> string(2) "01"
[1]=> string(2) "02"
[2]=> string(2) "03"
[3]=> string(2) "04"
[4]=> string(2) "05"
[5]=> string(2) "06"
[6]=> string(2) "07"
[7]=> string(2) "08"
[8]=> string(2) "09"
[9]=> int(10)
[10]=> int(11)
[11]=> int(12) }
我期待最後三個鍵的字符串。它是如何變成整數的?我應該怎麼做才能糾正這種現象?
http://php.net/manual/en/language.types.type-juggling.php – GWW
啊,動態類型語言的奇蹟... – nfechner