Question: I have the URL <http://api.minetools.eu/ping/play.desnia.net/25565> which outputs statistics of my server.

For example:

```
{
  "description": "A Minecraft Server",
  "favicon": null,
  "latency": 64.646,
  "players": {
    "max": 20,
    "online": 0,
    "sample": []
  },
  "version": {
    "name": "Spigot 1.8.8",
    "protocol": 47
  }
}

```

I want to get the value of online player count to display it on my website as: Online Players: online amount

Can anyone help?

I tried to do: 

```
<b> Online players: 

<?php
$content = file_get_contents("http://api.minetools.eu/ping/play.desnia.net/25565");
echo ($content, ["online"]);
}
?>
</b>

```

But it didn't work.

Answer: 
Your server is returning a JSON string.
So you should use **json\_decode()** function to convert that into a plain PHP object.
Thereafter you can access any variable of that object.

So, something like this shall help

```
<?php
$content =     file_get_contents("http://api.minetools.eu/ping/play.desnia.net/25565");

$result  = json_decode($content);

print_r( $result->players->online );
?>

```

More details for json\_decode can be read here -
<http://php.net/manual/en/function.json-decode.php>
Since it's returning an array you should use print\_r or var\_dump instead of echo. Or perhaps it threw you an error.