Hi. I am trying to search for text on a page. This is the page i am searching: http://www.ace-spades.com/serverlist.json. This is the code I have:
<?php
$link = "http://www.ace-spades.com/serverlist.json";
$linkcontents = file_get_contents($link);
$needle = "ServerIP";
$numofplayers = //I need help here
if (strpos($linkcontents, $needle) == false) {
echo "<center>0/12 Players online</center>";
} else {
echo "<center>$numofplayers/12 Players Online</center>";
}
?>
I need help locating the text after "count": (count is the number of players online the server) and getting the number. The example text is "count": 12. I want to make it so that it displays 12 and not the whole thing. Also I need to locate the example in this:
{"count": 5, "map": "(Server Map)", "uptime": 1436.2805321216583, "cumulative_uptime": 69137.85308456421, "name": "(server name)", "max": 12, "country": "(contry)", "identifier": "(server IP)", "game_mode": "(game mode)", "useless_ping": 99}
I need to locate the server IP, and then locate the "count": in the page. But only displaying the number after "count":. I would be glad if you helped. :D (the reason why I need to locate the server IP is that I don't want it to display random numbers, there are hundreds of servers on the page. The IP of the server is the key to get the amount of players on the server.)