我有個問題。我怎樣才能得到結果?這是我的代碼:<?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 關注
- 169 瀏覽
添加回答
舉報
0/150
提交
取消