0
內我有這樣的json項目在我的JSON文件PHP JSON打印陣列陣列
{
"results": [
{
"title": "Brick Mansions",
"released": "2014",
"restricted": "12 \u00e1ra",
"imdb": "6.0\/10 5,532 atkv.",
"imdbLink": "http:\/\/www.imdb.com\/title\/tt1430612",
"image": "http:\/\/kvikmyndir.is\/images\/poster\/9260_500.jpg",
"showtimes": [
{
"theater": "Laugar\u00e1sb\u00ed\u00f3",
"schedule": [
"20:00",
"22:00"
]
}
]
}
我想打印劇院和時間安排下用PHP。
我已經打印了一切。像這樣......不要忘記$ movys是包含json內容的對象。
<?php foreach($movys->results as $movie): ?>
<h2> <?php echo $movie->title; ?> </h2>
<div class="posters"><img src="<?php echo $movie->image; ?>" alt="Plakat fyrir <?php echo $movie->title; ?>"></div> <ul>
<li><p> <?php echo $movie->released; ?> </p></li>
<li><p> <?php echo $movie->restricted; ?> </p></li>
<li><p> <?php echo $movie->imdb; ?> </p></li>
<li><p> <?php echo $movie->imdbLink; ?> </p></li>
</ul>
?????? <?php foreach($movys->results{"showtimes"} as $hallo): ?>
?????? <h2><?php echo $hallo->theater; ?></h2>
?????? <?php endforeach; ?>
<?php endforeach; ?>
有解決方案的周圍gazillions [這裏](http://stackoverflow.com/search?q=php+recursive+array) –
爲什麼不'的foreach($ movie->放映時間爲$你好)'? – bloodyKnuckles
然後'foreach($ hallo-> schedule as $ s)' –