Your json_decode()
has a second parameter which determine the return type. By default, it will parse the JSON string into stdObject
, while you access it using indexes which is wrong
$server = Json_Decode(File_Get_Contents("http://query.fakaheda.eu/217.11.249.84:27408.feed"));
foreach($server->players_list as $player) {
echo '<span class="ipsGrid_span4">'.$player->name.'</span>';
echo '<span class="ipsGrid_span4">'.$player->score.'</span>';
echo '<span class="ipsGrid_span4">'.$player->time.'</span>';
}
To parse json string into array, use json_encode($jsonString, true)
$server = Json_Decode(File_Get_Contents("http://query.fakaheda.eu/217.11.249.84:27408.feed"), true);
foreach($server['players_list'] as $player) {
echo '<span class="ipsGrid_span4">'.$player['name'].'</span>';
echo '<span class="ipsGrid_span4">'.$player['score'].'</span>';
echo '<span class="ipsGrid_span4">'.$player['time'].'</span>';
}
solved Loop data from query