问题
I would like to know, how take the value "Tile32px" from this Json: (http://360api.chary.us/?gamertag=superdeder) with PHP.
I tried this way:
<?php
$json = file_get_contents('http://360api.chary.us/?gamertag=superdeder');
$gamer = json_decode($json);
echo $gamer->Gamertag;
echo "<br><br>";
$data = json_decode($json, true);
$users=$data['LastPlayed'];
foreach ($users as $user)
{
echo $user['Title'];
echo "<br>";
}
echo "<br>";
$users2=$data['Pictures'];
foreach ($users2 as $user2)
{
echo $user2['Tile32px'];
echo "<br>";
}
?>
This is the result:
SuperDeder
Skyrim Grand Theft Auto V FIFA 13 L.A. Noire WSOP: Full House Pro
h h h
Thanks a lot.
Andrea.
回答1:
Try this way.
<?php
$json = file_get_contents('http://360api.chary.us/?gamertag=superdeder');
$data = json_decode($json, true);
foreach ($data['LastPlayed'] as $val)
{
echo $val['Pictures']['Tile32px'];
echo "<br>";
}
?>
回答2:
Try this
<?php
$json = file_get_contents('http://360api.chary.us/?gamertag=superdeder');
$gamer = json_decode($json, true);
$users = $gamer['LastPlayed'];
foreach($users as $user){
echo $user['Pictures']['Tile32px'];
echo '<br>';
}
?>
来源:https://stackoverflow.com/questions/26606514/how-can-i-extract-the-value-of-this-json-in-php