我收到了一個數組,其中包含正在從兩個遊戲服務器中查詢的信息。它看起來像這樣:將數組值插入到html表中
Array (
[PERP] => Array (
[gq_address] => 192.168.1.1
[gq_dedicated] => d
[gq_gametype] =>
[gq_hostname] => Test Server 1
[gq_mapname] => gm_construct
[gq_maxplayers] => 60
[gq_mod] => garrysmod
[gq_numplayers] => 11
[gq_online] => 1
[gq_password] => 0
[gq_port] => 27016
[gq_protocol] => source
[gq_transport] => udp
[gq_type] => gmod
)
[TTT] => Array (
[gq_address] => 192.168.1.1
[gq_dedicated] => d
[gq_gametype] =>
[gq_hostname] => Test Server 2
[gq_mapname] => gm_construct
[gq_maxplayers] => 30
[gq_mod] => garrysmod
[gq_numplayers] => 0
[gq_online] => 1
[gq_password] => 0
[gq_port] => 27029
[gq_protocol] => source
[gq_transport] => udp
[gq_type] => gmod
)
)
然後我有一個表顯示數組中的信息。但是,目前它將兩臺服務器顯示在表中的同一行上。該表是這樣的:
<?php
echo '<table cellpadding="1" cellspacing="1" border="1">';
echo '<tr>';
foreach($results as $perp) {
echo '<td>' . $perp['gq_type'] . '</td>';
echo '<td>' . $perp['gq_online'] . '</td>';
echo '<td>' . $perp['gq_hostname'] . '</td>';
echo '<td>' . $perp['gq_address'] . '</td>';
echo '<td>' . $perp['gq_port'] . '</td>';
echo '<td>' . $perp['gq_numplayers'] . '</td>';
echo '<td>' . $perp['gq_mapname'] . '</td>';
}
echo '</tr>';
echo '</table>';
?>
所以目前它在表中同一行打印「測試服務器1」和「測試服務器2」並重。我該如何製作一個表格來分隔兩行中的兩個數組?
在這裏你可以看到表:http://zfrag.se/servers.php
把'