我有一個數組包含JSON在一些索引,我有將其解碼如何JSON解碼的多維陣列
例如:
這是JSON
$json = {"Lavel1":"This is Lavel1","LavelLoop":"{\"Lavel2\":\"This is Lavel2\",\"LavelLoop\":\"{\\\"Lavel3\\\":\\\"This is Lavel3\\\",\\\"LavelLoop\\\":[]}\"}"}
如果是第一次解碼,那麼它給這個數組
$array = json_decode($json);
// this is the output
Array
(
[Lavel1] => This is Lavel1
[LavelLoop] => {"Lavel2":"This is Lavel2","LavelLoop":"{\"Lavel3\":\"This is Lavel3\",\"LavelLoop\":[]}"}
)
所以我有解碼了三次,但我不能假設它有多少次JSON包含
慾望輸出應該是這樣的
Array
(
[Lavel1] => This is Lavel1
[LavelLoop] => Array
(
[Lavel2] => This is Lavel2
[LavelLoop] => Array
(
[Lavel3] => This is Lavel3
[LavelLoop] => Array
(
)
)
)
)
我試過循環,但它不工作,它給了我像一些索引顯示錯誤n me empty
'$結果= json_decode( '<多維陣列>',TRUE);' – Haridarshan
你有沒有嘗試過,因爲我知道這個功能,但JSON包含它自我一個子JSON – User97798
我已更新的問題看看 – User97798