我想這個字符串轉換:對象數組作爲字符串到對象數組(jSON)?
$json = '[{"a":1,"b":2,"c":3,"d":4,"e":5}, {"a":6,"b":7,"c":8,"d":9,"e":10}]';
爲對象的數組。我試過了:
$test = json_decode($json, true);
echo sizeof($test); //traces 2 !
echo $test[0]["a"]; //doesn't echo anything!
我如何在PHP中將json字符串轉換爲對象數組?
假設json被解析成一個對象數組,試試'$ test [0] - > a' – 2012-03-29 17:38:04
謝謝,你應該做出了一個「真實」的答案;) – Eric 2012-03-29 17:39:26
好吧,我發佈它作爲答案:) – 2012-03-29 17:40:11