我有个问题。我怎样才能得到结果?这是我的代码:<?php $api_e = file_get_contents('https://omnihost.tech/dashboard/hosts/'.$slug.'/api_ftp');$api = json_decode($api_e); ?><?php foreach($api as $file){ ?> <tr> <td>#</td> <td><?= $file; ?></td> <td>--</td> </tr><?php } ?>我的 JSON 是:{"data": [".","..",".editorconfig",".gitignore",".htaccess",".well-known","README.md","application","assets","cgi-bin","composer.json","contributing.md","index.php","license.txt","readme.rst","system"]}错误:http : //prntscr.com/o98xau
2 回答
12345678_0001
TA贡献1802条经验 获得超5个赞
您需要指定您需要打印的列,您可以尝试在下面打印文件名
<td><?= $file['12']; ?></td>
否则,您将循环打印数组中的所有数据,使用 2 个循环
<?php foreach($api as $file) { ?>
<?php foreach($file as $i => $item) { ?>
<tr>
<td><?= $i; ?></td>
<td><?= $item; ?></td>
<td>--</td>
</tr>
<?php } ?>
<?php } ?>
- 2 回答
- 0 关注
- 150 浏览
添加回答
举报
0/150
提交
取消