一旦我得到這個代碼打印只在最後的foreach
$servers = array(
array(
'type' => 'tf2',
'host' => '193.192.59.191:27015',
),
array(
'type' => 'tf2',
'host' => '193.192.59.191:27025',
),
array(
'type' => 'tf2',
'host' => '193.192.59.191:27035',
),
array(
'type' => 'tf2',
'host' => '193.192.59.191:27045',
),
array(
'type' => 'tf2',
'host' => '193.192.59.191:27055',
),
array(
'type' => 'tf2',
'host' => '193.192.59.191:27065',
),
array(
'type' => 'tf2',
'host' => '193.192.59.191:27075',
),
);
$totalcount = 0;
function print_results($results) {
foreach ($results as $id => $data) {
print_table($data);
}
}
function print_table($data) {
global $totalcount;
$totalcount = $totalcount + $data['gq_maxplayers'];
echo $totalcount;
}
if (!$data['gq_online']) {
}
printf("</tr></tbody>");
}
而且我希望它呼應只有在它PRINT_TABLE最後一次,所以只能將再次顯示它(在它最後一次功能)。而不是每次它執行該功能。我會怎麼做?謝謝!
我不認爲你粘貼完整的代碼。有缺少電話.. –