0

下面是我想要访问的示例 json 代码......这个 json 实际上来自 API。每当我将整个 json 复制并粘贴到 json lint 中时。它说有效的 json ..

foreach ($movies as $movie) {
echo "theaters ".var_dump($movie->release_dates->theater)";
}

//Im actually trying to access a nested json in php... Something like
{
"movies":[{
"tile":"Cowboys";
"release_dates":{"theater":"2013-11-29"}, 
so on....

每当我尝试写上面的内容时,它都会给我一个错误Object of stdclass cannot be converted to string....或者如果我写

$x = json_decode(var_dump($movie->release_dates->theater), true)";
echo "theaters "$x[0];

它给出了一个输出string[10]:2013-11-25 string[10]:2013-11-30......等等......错误是什么......

4

1 回答 1

0
$data = json_decode($movies, true);

foreach ($data as $movie) {
   echo "theaters ".implode(', ', $movie->release_dates->theater)";
}
于 2013-10-31T20:42:16.530 回答