Reputation: 11
require('mq_class.php');
print_r(Minequery::query("64.31.24.137"));
returns:
Array ( [serverPort] => 25565 [playerCount] => 6 [maxPlayers] => 40 [playerList] => Array ( [0] => Uthly [1] => epson8 [2] => CheeseBricks [3] => Truth92 [4] => zerokhaos [5] => plainlazy95 ) [latency] => 25.8100032806 )
Now, how would I read, say serverPort
(a variable) or playerList
(which is an array)?
I've done PHP for a while now, I guess I know only a little amount.
Upvotes: 0
Views: 157
Reputation: 33901
$serverDetails = Minequery::query("54.31.24.137");
$serverPort = $serverDetails['serverPort'];
echo $serverPort; //25565
$playerList = $serverDetails['playerList'];
print_r($playerList); //Array ( [0] => Uthly [1] => epson8 [2] => CheeseBricks [3] => Truth92 [4] => zerokhaos [5] => plainlazy95 )
Upvotes: 0
Reputation: 22152
Use this code:
$array = Minequery::query("64.31.24.137");
echo $array['serverPort']; // will print 25565
print_r($array['playerList']); // will print the subarray info
Upvotes: 2
Reputation: 72981
$data = Minequery::query("64.31.24.137");
echo $data['serverPort'];
echo $data['playerList'][0];
Read up on PHP Arrays
Upvotes: 1