PHP Массив, конкретное эхо c ID - PullRequest
0 голосов
/ 04 мая 2020

Я новичок в PHP и хочу вывести специфицированный c id из массива. Если бы вы могли помочь мне, как это должно выглядеть, я действительно это понимаю.

$playersStr = "7656654642192473"
              "8686868682192473";

$players = array();             

$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=2987978A4898+2F66hfhfht17FE4&steamids=$playersStr";
$json_object= file_get_contents($url);
$json_decoded = json_decode($json_object);

foreach ($json_decoded->response->players as $player)
{
    $players[$player->steamid]['personaname'] = $player->personaname;
} 

Итак, вопрос в том, как я могу напечатать и то, и другое? Первый и второй.

echo $players[$player->steamid]['personaname'] = $player->personaname; //first
echo $players[$player->steamid]['personaname'] = $player->personaname; //second

1 Ответ

0 голосов
/ 05 мая 2020

Думаю, можно использовать

foreach ($json_decoded->response->players as $key=>$player){
       print_r($key)
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...