Answer the question
In order to leave comments, you need to log in
How to display the desired value from a specific JSON array using PHP?
Hello!
There is a JSON array that is loaded from a third-party resource:
{
"playerstats": {
"steamID": "76561197972495328",
"gameName": "ValveTestApp260",
"stats": [
{
"name": "total_kills",
"value": 2199
},
{
"name": "total_deaths",
"value": 1501
},
{
"name": "total_time_played",
"value": 115235
}
]
}
}
$json_csgo_user_info = file_get_contents('http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key='.$steam_api_key.'&steamid='.$user_steam_id); //Получение JSON
$json_csgo_user_info = json_decode($json_csgo_user_info)->playerstats->stats;
echo $json_csgo_user_info[1]->value; //Вывод
Answer the question
In order to leave comments, you need to log in
Вы правы, так действительно лучше не делать.
Но удобного способа сделать это на php нет.
Вы можете:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question