如何在php中提取这个json的值?

时间:2014-10-28 10:55:57

标签: php json image long-integer xbox

我想知道,如何从这个Json取值“Tile32px”: (http://360api.chary.us/?gamertag=superdeder)与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

天际 侠盗猎车手V FIFA 13 L.A. Noire WSOP:Full House Pro

ħ H ħ

非常感谢。
安德烈。

2 个答案:

答案 0 :(得分: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>';
    }
?>

答案 1 :(得分: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>";
    }   

?>