这是我要编码为 JSON 的数组的 var_dump:
array(3) {
[0]=> array(2) {
["From"]=> string(14) "08 August 2013"
["To"]=> string(14) "21 August 2013"
}
[1]=> array(2) {
["From"]=> string(14) "11 August 2013"
["To"]=> string(14) "21 August 2013"
}
[2]=> array(2) {
["From"]=> string(14) "12 August 2013"
["To"]=> string(14) "01 August 2013"
}
}
当我对其进行编码时,输出如下所示:
[
{"From":"08 August 2013","To":"21 August 2013"},
{"From":"11 August 2013","To":"21 August 2013"},
{"From":"12 August 2013","To":"01 August 2013"}
]
但我希望它是这样的:
{
0:{"From":"08 August 2013","To":"21 August 2013"},
1:{"From":"11 August 2013","To":"21 August 2013"},
2:{"From":"12 August 2013","To":"01 August 2013"}
}
这是可能的,因为我以前做过,但是现在使用相同的代码将无法正常工作