我有这样的数组。在json编码后,我发现这些像第一个结果。但我希望我的数组像第二个数组
Array
(
[2017-09-10] => 178934.35
[2017-09-09] => 700000
[2017-09-07] => 194432.25
[2017-09-06] => 183252.9
[2017-09-03] => 1311.45
[2017-09-02] => 1186.55
[2017-08-30] => 204660.3
[2017-08-29] => 290486.45
[2017-08-28] => 2400
[2017-08-27] => 600.00
[2017-08-26] => 840.00
[2017-08-16] => 600.00
)
json编码后的第一个结果。
{"2017-09-10":178934.35,"2017-09-09":700000,"2017-09-07":194432.25,"2017-09-06":183252.9,"2017-09-03":"1311.45","2017-09-02":"1186.55","2017-08-30":204660.3,"2017-08-29":290486.45,"2017-08-28":2400,"2017-08-27":"600.00","2017-08-26":"840.00","2017-08-16":"600.00"}
必需的数组格式
Array
(
[0] => Array
(
[cols] => 2017-09-10
[rows] => 177622.91
)
)
在json Enconding之后
[{"cols":"2017-09-10","rows":177622.91} {"cols":"2017-09-10","rows":177622.91}]
答案 0 :(得分:1)
迭代你的数组并构建一个新数组:
sudo apt-get install php-sqlite3