What is the purpose of extracting values from a Gameserver Query using PHP?

When working with a Gameserver Query, extracting values using PHP allows developers to access important information about the server, such as the number of players, server name, map being played, and more. This information can be used to display server status on a website, create leaderboards, or automate server management tasks.

<?php
// Connect to the Gameserver Query
$server = new GameQ();
$server->addServer([
    'type' => 'source', // Type of server (e.g. source, minecraft, etc.)
    'host' => 'server_ip',
    'port' => 'server_port'
]);
$data = $server->process();
$serverInfo = $data['server_ip:server_port']; // Replace with actual server IP and port

// Extracting values
$serverName = $serverInfo['gq_hostname'];
$map = $serverInfo['gq_mapname'];
$players = $serverInfo['gq_numplayers'];

// Display the extracted values
echo "Server Name: $serverName";
echo "Map: $map";
echo "Players: $players";
?>