用于对日期数组json_encode
进行编码,它有时会做一件事,有时会做另一件事。
例如,如果我试图编码类似:
array(6) {
[0]=>
string(6) "Jun-24"
[1]=>
string(6) "Jun-25"
[2]=>
string(6) "Jun-28"
[3]=>
string(11) "Training-24"
[4]=>
string(6) "Jun-29"
[5]=>
string(6) "Jun-30"
}
它会输出
["Jun-24","Jun-25","Jun-28","Training-24","Jun-29","Jun-30"]
但是,当我尝试对以下内容进行编码时:
array(17) {
[0]=>
string(6) "Jun-23"
[1]=>
string(6) "Jun-24"
[2]=>
string(6) "Jun-28"
[3]=>
string(11) "Training-24"
[4]=>
string(6) "Jun-29"
[5]=>
string(6) "Jun-30"
[6]=>
string(6) "Jul-06"
[7]=>
string(6) "Jul-07"
[9]=>
string(6) "Jul-09"
[10]=>
string(6) "Jul-16"
[11]=>
string(6) "Jul-17"
[12]=>
string(6) "Jul-20"
[13]=>
string(6) "Jul-23"
[14]=>
string(6) "Jul-24"
[15]=>
string(6) "Jul-30"
[16]=>
string(6) "Aug-01"
[17]=>
string(6) "Aug-05"
}
它会输出
{"0":"Jun-23","1":"Jun-24","2":"Jun-28","3":"Training-24","4":"Jun-29","5":"Jun-30","6":"Jul-06","7":"Jul-07","9":"Jul-09","10":"Jul-16","11":"Jul-17","12":"Jul-20","13":"Jul-23","14":"Jul-24","15":"Jul-30","16":"Aug-01","17":"Aug-05"}
(抱歉,找不到失败的较小示例)
重点是,为什么要这样做?选项相同,数组结构相同,有什么问题?