我是JavaScript和PHP的新手。我已經閱讀了多個堆棧的答案,但我的JSON字符串有點不同。如果你問我,其實很簡單。多維JSON數組到多〜php陣列不工作
的字符串如下:
[[{"height":"444","width":"444","picture":"/image/data/122.jpg","x":0,"y":0,"currentheight":"444"},{"height":"444","width":"444","picture":"/image/data/122.jpg","y":"444","x":0,"currentheight":888},{"height":"223","width":"444","picture":"/image/data/122.jpg","y":888,"x":0,"currentheight":1111}],[{"height":"223","width":"444","picture":"/image/data/122.jpg","y":0,"x":444,"currentheight":"223"},{"height":"223","width":"444","picture":"/image/data/122.jpg","y":"223","x":444,"currentheight":446}]
現在我想將它與json_decode($jsonstring, true)
解碼,但它只是當我被它的指數調用它沒有得到一個值。只要我嘗試使用echo $jsonstring[0]
獲取數據,我就得到[
。 $jsonstring[0]['width']
甚至不返回任何東西。
我說他們錯了嗎?還是別的嗎?
缺少右']? – guest271314
你有一個矩陣/表;一組數組。首先你需要解碼json'$ table = json_decode($ jsonstring,true)'然後你可以得到一個Object'$ row = $ table [0];''item = $ row [0];'現在你可以獲取屬性如'width''echo'width:'。 $ item ['width'];'或'var_dump($ item);'。你需要了解你正在處理widh的數據結構。 – Thomas