-1
我有一個這樣的數組。在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}]
簡單'foreach'就夠這裏。 –
@u_mulder請幫忙 –