2 回答
TA贡献2021条经验 获得超8个赞
torrents响应键的所有数据。您应该检查数组索引/键是否存在。
<?php
$url = 'https://eztv.io/api/get-torrents?limit=100&page=1'; // path to your JSON file
$data = file_get_contents($url); // put the contents of the file into a variable
$shows = json_decode($data, true); // decode the JSON feed and make an associative array
<?php foreach ($shows['torrents'] as $shows) : ?>
<tr></tr>
<?php endforeach; ?>
TA贡献1886条经验 获得超2个赞
foreach ($shows as $shows) : ?>
<tr>
<td> <strong><?php echo $shows["title"] ?? '' . "\n"; ?></strong> </td>
<td> <strong><?php echo $shows["season"] ?? '' . "\n"; ?></strong> </td>
<td> <strong><?php echo $shows["episode"] ?? '' . "\n"; ?></strong> </td>
<td> <a href="<?php echo $shows["magnet_url"] ?? '' . "\n"; ?>">magnet</a></td>
<td> <?php echo $shows["date_released_unix"] ?? '' . "\n"; ?> </td>
<td> <?php echo $shows["size_bytes"] ?? '' . "\n"; ?> </td>
<td> <a href="<?php echo $shows["episode_url"] ?? '' . "\n"; ?>">episode Link</a></td>
<td> <?php echo $shows["imdb_id"] ?? '' . "\n"; ?> </td>
</tr>
<?php endforeach; ?>
类似于 Shivendra Singh 的回答,但我们使用空合并只是为了让事情更容易阅读。
- 2 回答
- 0 关注
- 173 浏览
添加回答
举报