【发布时间】:2014-08-02 11:01:58
【问题描述】:
我已经尝试了几个小时来创建一个包含来自 JSON 数组的数据的简单表。
下面是一个例子。我不知道为什么这段代码不起作用。错误是:
“试图获取非对象的属性”。
$json_string = file_get_contents("https://bittrex.com/api/v1/public/getmarkethistory?market=BTC-HYPER&count=5");
$array = json_decode($json_string);
?>
<table><tr><th>
<?php foreach($array as $o): ?>
<tr>
<td><?php $o->result->TimeStamp ?></td>
</tr>
<?php endforeach; ?>
</table>
请查看 json_string 的 URL 以进行格式化。
【问题讨论】:
-
foreach($array->result as $o)和$o->TimeStamp?你也应该使用echo -
如果你想为此使用 Jquery 这里是链接 1- zachhunter.com/2010/04/json-objects-to-html-table , 2- stackoverflow.com/questions/1051061/…
标签: php html json html-table