【发布时间】:2015-12-15 17:31:35
【问题描述】:
我似乎不知道如何打印一个漂亮的有序表。
我希望最多有 7 列,它可以根据数组的大小生成所需的行数。该数组是通过一个可以随时更新的 URL。 (它是 Steam 上的玩家库存)。
$id = $steamprofile['steamid'];
$key = 'XXXXXXXXXXXXXXXXXXXX';
if($id != null){
$inv = file_get_contents('http://steamcommunity.com/profiles/'.$id.'/inventory/json/730/2');
$inventory = json_decode($inv, true);
$price = file_get_contents('values/response.json');
$value = json_decode($price, true);
foreach ($inventory['rgDescriptions'] as $rgDescription) {
for($i = 0; sizeof($rgDescription['market_name']) > $i; $i++){
if(isset($rgDescription['market_name'])){
print '<td><img src="https://steamcommunity-a.akamaihd.net/economy/image/'.$rgDescription['icon_url'].'" alt="'.$rgDescription['market_name'].' width="80" height="75"></td>';
}
}
}
}
数组位于here,如果您需要查看它。
我可以打印出表格,但它总是重复我不想要的项目。那么我该如何解决呢?非常感谢任何建议。
【问题讨论】:
-
JSON 完全不可读,因为浏览器会逃避缩进。您可以在此处粘贴代码格式,在您的问题中,它的相关部分吗?
-
首先,打印你的表格: echo '
' , print_r($inventory , true) , '
';看看你的代码是否与你尝试的匹配
标签: php html arrays multidimensional-array html-table