<?php
$response = file_get_contents("http://api.trakt.tv/shows/trending.json/5d7588c188eeea0074b8d2664d12fffc");
$result = json_decode($response, true);
echo $result['title'][0];
echo "<br>";
echo $result['network'][0];
echo "<br>";
echo $result['air_day'][0];
echo "<br><img style='width:200px;' src='";
echo $result['images'][0]['poster'];
echo "'>";
?>
不工作。我不知道为什么。
我使用trakt.tv显示API。
答案 0 :(得分:2)
写
echo $result[0]['title'];
而不是
echo $result['title'][0];
此外,PHP的echo函数将打印整数和字符串,但是会出现类似于数组的结构。您可以使用var_dump或var_export。多亏了他们,你可以扫描结构,你不会问这个问题;)