PHP code example of jacklul / q3serverlist

1. Go to this page and download the library: Download jacklul/q3serverlist library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jacklul / q3serverlist example snippets


use jacklul\q3serverlist\MasterServer;
use jacklul\q3serverlist\Server;

 $ms->getServers(); // Second call will always return cached data, same with Server->getInfo and Server->getStatus

/** @var Server $server */
foreach ($servers as $server) { 
	$info = $server->getInfo();	// 'getinfo' request usually returns map name
	
	// Find first server with map 'q3dm17' (The Longest Yard) and print it's status
	if (isset($info['mapname']) && $info['mapname'] === 'q3dm17') {
		print_r($server->getStatus());
		break;
	}
}

// You can get status/info variables magically like this:
$server->getMapname();

// To get variables that