0
如何让我的表动态列出它从api中提取的所有值,atm只抽出1条记录并将其放入表中,其余数据放在表中使用API数据创建动态表
可能是一些非常小的,我在这里失踪,但不能把我的手指上
感谢您的帮助,非常赞赏。
<?php
$trackingId = $_POST['trackingId'];
if (isset($_POST['trackingId'])) {
$fetch = json_decode(file_get_contents(sprintf('apigoeshere', $trackingId)));
if ($fetch->status != 'OK') {
echo sprintf('Error: %s', $fetch->message);
} else {
//example how to access statistics variable
$inactiveAccounts = $fetch->statistics->inactiveAccounts;
echo sprintf('Inactive accounts: %d' . "<br /><br />", $inactiveAccounts);
?>
<table border="1">
<tr>
<th>Account name</th>
<th>Level</th>
</tr>
<?php
//example how to display all accounts username
foreach ($fetch->accounts as $account) {
?>
<tr>
<td><?php
echo $account->username;
?></td>
<td><?php
echo $account->currentLevel;
?></td>
</tr>
</table>
<?php
}
}
}
?>
您可以只执行echo count($ fetch-> accounts);'查看'array'的'length'返回的是什么? – 2014-10-09 09:36:27