-3

I would like to know, how take the value "gamertag" from this Json (http://360api.chary.us/?gamertag=superdeder) with PHP.

i would print only the value "superdeder".

thanks a lot.

Andrea.

1 Answers1

3

Use file_get_contents() and convert your JSON to an object with json_decode():

$json = file_get_contents('http://360api.chary.us/?gamertag=superdeder');

$gamer = json_decode($json);
echo $gamer->Gamertag; // SuperDeder

Or, an array, by passing a truthy value as json_decode()s second parameter:

$gamer = json_decode($json, true);
echo $gamer['Gamertag']; // SuperDeder
George
  • 36,413
  • 9
  • 66
  • 103