PHP如何回显JSON对象(noob问题)

问题描述 投票:0回答:1

我尝试用explode()函数回显JSON对象,但是我没有成功,我认为我使用了错误的方法,但是我找不到其他方法来做到这一点

我想像看起来似乎很简单,但是我是一个初学者,对我来说真的很难。 { "Title_Book": "Harry Potter", "Volume": [ { "Name": "Harry Potter and the Philosopher's Stone", "Actor": [ { "Actor": "Actor0" }, { "Actor": "Actor1" } ] }, { "Name": "Harry Potter and the Chamber of Secrets", "Actor": [ { "Actor": "Actor0" } ] } ] }{ "Title_Book" : Another Book ... }

收件人

`
Title : Book
Volume[0][0] : Name of the book : Harry Potter and the Philosopher's Stone
Volume[0][1] : Actor 1
Volume[0][2] : Actor 1 
Volume[1][0] : Name of the book : Harry Potter and the Chamber of Secrets
Volume[1][1] : Actor 0 

Title1 ...
`
php json printing echo explode
1个回答
0
投票
示例代码:

$booksArray = json_decode($libraryJsonString,true); foreach ($booksArray as $books) { print_r($books); }

而不是print_r($booksArray);,您可以放置​​另一个foreach循环来遍历数组的每个元素。查看数组在解码后看起来如何正确使用:

$booksArray = json_decode($libraryJsonString,true);
print_r($booksArray);
© www.soinside.com 2019 - 2024. All rights reserved.