Search code examples
phpjsonimagelong-integerxbox

How can I extract the value of this json in php?


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.


Solution

  • 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>";
        }   
    
    ?>