1

Error Noticed : undefined offset: 0 Line 37

Line 37

$table = (table2)["response"]["players"][0];

Small Cut

    ");
}

$steamid64 = $_GET["steamid"];

$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . $SteamAPIKey . "&steamids=" . $steamid64;
$json = file_get_contents($url);
$table2 = json_decode($json, true);
//Undefined Variable which means it hasn't been Verified.
$table = $table2["response"]["players"][0];
print_r($table2);

?>
Draco
  • 13
  • 1
  • 6
  • 1
    Clearly there are no elements in the `"players"` collection. The code assumes there are. Hence the error. – David Aug 07 '16 at 14:15
  • 1
    Possible duplicate of [Notice: Undefined offset: 0 in](http://stackoverflow.com/questions/6549561/notice-undefined-offset-0-in) – FirstOne Aug 07 '16 at 14:24

1 Answers1

0

You can use print_r($table2); to see how $tables is structured before you get the first item of players.

For example: Replace

$table = $table2["response"]["players"][0];
print_r($table2);

By

print_r($table2);
$table = $table2["response"]["players"][0];
Tung Nguyen
  • 767
  • 7
  • 6