2014-10-28 2 views
0

Я хотел бы знать, как взять значение «Tile32px» из этого Json: (http://360api.chary.us/?gamertag=superdeder) с PHP.Как я могу извлечь значение этого json в php?

Я попробовал этот путь:

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

Это результат:

SuperDeder

Skyrim Grand Theft Auto V FIFA 13 LA Noire WSOP: Full House Pro

h h h

Большое спасибо.
Andrea.

+1

'var_dump ($ геймер)' PS: почему вы 'json_decode' дважды? – zerkms

ответ

0

Попробуйте этот путь.

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

?> 
1

Попробуйте

<?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>'; 
    } 
?> 
Смежные вопросы