Answer the question
In order to leave comments, you need to log in
How to pull the desired parameter from JSON in PHP?
Here is the JSON string itself:
{"_id":50625,"ip":"91.218.231.190","domain":"craftm.ru","port":25565,"url":["http:\/\/craftm.smates.ru","https:\/\/vk.com\/craftm_ru","http:\/\/smates.ru"],"date_add":1449142061,"status":1,"scan":1,"uptime":"83.33","last_update":1449240685,"geo":{"country":"RU","country_name":"\u0420\u043e\u0441\u0441\u0438\u044f","city":"Moscow"},"info":{"name":"CraftM | Sofros 1.8.8","type":"SMP","platform":"MINECRAFT","version":"1.8.8","plugins":["AutoMessage 2.5.4"," MOTDColor 0.5"," SignColorz 2.1"," RandomTeleport maven-version-number"," WorldEdit 6.1,no_git_id"," iConomy 6.0.10b"," MassiveCore 2.8.0"," MuteManager 0.16-34"," Vault 1.5.6-b49"," ClearLag 2.8.3"," PermissionsEx 1.23.3"," AutoSaveWorld 4.14.2"," WorldGuard 6.0.0-beta-03.1514-"," Essentials TeamCity"," EssentialsProtect TeamCity"," ServerSigns 4.3.3"," EssentialsSpawn TeamCity"," CreativeGates 2.8.0"," ChestShop 3.8.12"," EssentialsChat TeamCity"," EssentialsAntiBuild TeamCity"," AuthMe 5.0-SNAPSHOT"," Factions 2.7.5"],"players":4,"max_players":40,"players_list":["Kakamen","Tema0302","ugorek","dasasa"],"map":"world","software":"CraftBukkit on Bukkit 1.8.8-R0.1-SNAPSHOT","avg_player_day":0.78,"avg_load_day":1.94},"counter":{"online":221,"offline":44,"players":{"date":"2015-12-04","total":0},"favorite":1,"cmts":0},"rating":{"main":4.53,"difference":-0.9,"content_up":0.3,"K":7.16},"last":{"offline":1449168085,"online":1449240685},"chart":{"13:30":3,"13:40":3,"13:50":0,"14:00":1,"14:10":2,"14:20":2,"14:30":2,"14:40":3,"14:50":3,"15:00":4,"15:10":5,"15:20":5,"15:30":5,"15:40":5,"15:50":6,"16:00":6,"16:10":6,"16:20":7,"16:30":8,"16:40":7,"16:50":4,"17:00":0,"17:10":0,"17:20":0,"17:30":0,"17:40":0,"17:50":0,"18:00":0,"18:10":0,"18:20":0,"18:30":0,"18:40":0,"18:50":0,"19:00":0,"19:10":0,"19:20":0,"19:30":0,"19:40":0,"19:50":0,"20:00":0,"20:10":0,"20:20":0,"20:30":0,"20:40":0,"20:50":3,"21:00":2,"21:10":2,"21:20":1,"21:30":1,"21:40":0,"21:50":0,"22:00":0,"22:10":0,"22:20":0,"22:30":0,"22:40":0,"22:50":0,"23:00":0,"23:10":0,"23:20":0,"23:30":0,"23:40":0,"23:50":0,"00:00":0,"00:10":0,"00:20":0,"00:30":0,"00:40":0,"00:50":0,"01:00":0,"01:10":0,"01:20":0,"01:30":0,"01:40":0,"01:50":0,"02:00":0,"02:10":0,"02:20":0,"02:30":0,"02:40":0,"02:50":0,"03:00":0,"03:10":0,"03:20":0,"03:30":0,"03:40":1,"03:50":1,"04:00":0,"04:10":0,"04:20":0,"04:30":0,"04:40":0,"04:50":0,"05:00":0,"05:10":0,"05:20":0,"05:30":0,"05:40":0,"05:50":0,"06:00":0,"06:10":0,"06:20":0,"06:30":0,"06:40":0,"06:50":0,"07:00":0,"07:10":0,"07:20":0,"07:30":0,"07:40":0,"07:50":0,"08:00":0,"08:10":0,"08:20":0,"08:30":0,"08:40":0,"08:50":0,"09:00":0,"09:10":1,"09:20":0,"09:30":0,"09:40":0,"09:50":0,"10:00":0,"10:10":0,"10:20":0,"10:30":0,"10:40":0,"10:50":0,"11:00":0,"11:10":0,"11:20":0,"11:30":0,"11:40":0,"11:50":1,"12:00":0,"12:10":2,"12:20":2,"12:30":2,"12:40":2,"12:50":2,"13:00":2,"13:10":2,"13:20":2},"uri":"cm-s1-sofros","map_url":"","download_url":"","mods":["nolicense","private","pvp","survival","clans","parkur"],"max_stat":{"max_online":{"date":1449239485,"players":8}},"cover":"50625_204cafeb47b61615f9e709023bcaf464","status_query":"ok"}
function gg($server_id, $param){
$json_code = file_get_contents('https://minecraft-statistic.net/ru/server/'.$server_id.'/json/');
$json = json_encode($json_code);
return $json->info->$param;
}
$server_id = '50625';
$param = 'players';
echo gg($server_id, $param);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question