How to get Arma server player count with Steam api in PHP

An under used Steam api feature is getting server information such as players, map, name, location and version. Here is how to do it using DayZ mod as an example.

The php file consists of the following:

$data = json_decode(file_get_contents('\appid\224580\addr\'));
$main = $data->response->servers[0];
$name = $main->name;
$address = $main->addr;
$version = $main->version;
$players = $main->players;
$map = $main->map;
$bots = $main->bots;
echo "Server: $name<br>Address: $address<br>Players: $players<br>Bots: $bots<br>Map: $map<br>Version: $version";

*You need a Steam api key

The $data variable has filters of appid and addr . The appid is a number steam gives to a game (730 is csgo etc), addr is the servers ip address and steamport (steamport is one more than the connection port ie 2303 2302).

To use the above script for your needs you need to edit the appid, addr and add your Steam api key. Then you can follow how i went through the array to get the data like players, map, name, location and version.