我正在嘗試添加特定變量(gq_numplayers)並將其顯示出來。如果數組在數組中,我該怎麼做? 如果你不明白髮生了什麼,我正在使用GameQ(https://github.com/Austinb/GameQ/)。將數組中的數值相加
編輯: var_dump($ results); http://pastebin.com/BSeeWMEb
<?php
// Include the main class file
require '../GameQ.php';
// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
array(
'id' => 'server 1',
'type' => 'css',
'host' => '216.52.148.30',
),
array(
'id' => 'server 2',
'type' => 'css',
'host' => '216.52.143.83',
),
array(
'id' => 'server 3',
'type' => 'teamspeak3',
'host' => 'voice.xenogamers.org:8730',
)
);
// Init the class, only need this once
$gq = new GameQ();
$gq->addServers($servers);
//optional settings
$gq->setOption('timeout', 3); // Seconds
$gq->setOption('debug', TRUE);
// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
// Send requests, and parse the data
$results = $gq->requestData();
//make total
$total = array_sum(?!?!?!??!?!?);
echo $results['server 1']['gq_numplayers'];
?>
我看不出gq_numplayers填充 – 2012-11-09 03:29:00
貌似gq_numplayers必須根據requestData進行計算。如果是這樣,var_dump $結果並將其添加到問題。 – janenz00