如何在php中提取这个json的值? [英] How can I extract the value of this json in php?
本文介绍了如何在php中提取这个json的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道,如何从这个Json取值Tile32px:
()。
I would like to know, how take the value "Tile32px" from this Json: (http://360api.chary.us/?gamertag=superdeder) with 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
SuperDeder
Skyrim
侠盗猎车手V
FIFA 13
LA Noire
WSOP:Full House Pro
Skyrim Grand Theft Auto V FIFA 13 L.A. Noire WSOP: Full House Pro
h
h
h
h h h
非常感谢。
Andrea。
Thanks a lot.
Andrea.
推荐答案
试试这种方式。
<?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>";
}
?>
这篇关于如何在php中提取这个json的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文