我知道这个问题已经重复,但我不能按照我的情况说明这些例子。我正在查询Quake 2服务器以获取个人项目
foreach ($results as $data) {
echo "<pre>";
print_r($data['players']);
}
获得的信息:
[0] => Array
(
[frags] => 7
[ping] => 28
[nick] => Player
[gq_name] => Player
[gq_score] => 7
[gq_ping] => 28
)
[1] => Array
(
[frags] => 27
[ping] => 31
[nick] => lE'Heineken.
[gq_name] => lE'Heineken.
[gq_score] => 27
[gq_ping] => 31
)
)
那么如何在简单的表格中移动此信息呢?
<table>
<tr>
<th>Players</th>
<th>Frags</th>
<th>Ping</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
我正在尝试做q2servers
之类的事情感谢您的时间,对不起我的英语。此致
答案 0 :(得分:0)
我真的不需要你,但如果我理解得很好,你需要的是:
items = $("a");
$(items).each(function(index, item){
b = $(item).attr('href');
c = b.replace("#", "");
d = "http://www.domainname.com/index/" + c + "/get";
//console.log(d); //just to check them out
item.attr('href', d);
});
答案 1 :(得分:0)
我认为你需要这个:
echo "
<table>
<tr>
<th>Players</th>
<th>Frags</th>
<th>Ping</th>
</tr>";
foreach ($results as $data) {
// print_r($data['players']);
echo "
<tr>
<th>".$data['players']['nick']."</th>
<th>".$data['players']['frags']."</th>
<th>".$data['players']['ping']."</th>
</tr>"
}
echo "</table>";
答案 2 :(得分:0)
然后试试这个,
<table>
<tr>
<th>Players</th>
<th>Frags</th>
<th>Ping</th>
</tr>
<?php foreach ($results as $data) {
<?php foreach($data['players'] as $item){ ?>
<tr>
<td><?php echo $item['gq_name']; ?></td>
<td><?php echo $item['gq_frags']; ?></td>
<td><?php echo $item['ping']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</table>