如何获得JSON数据在PHP? [英] How to get JSON data in php ?
本文介绍了如何获得JSON数据在PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何从一个JSON对象获取数据,因为这与PHP?:
[
{
名:安德斯
},
{
名:克里斯
},
{
名:彼得,
}
]
这是PHP code我有:
$ URL =的http:// urltotheapi';
$内容=的file_get_contents($网址);
$ JSON = json_de code($内容,真实);
解决方案
的foreach($ JSON作为$ I){
回声$ I ['名'];
}
How do I get the data from an JSON object as this with PHP?:
[
{
"name": "Anders",
},
{
"name": "Chris",
},
{
"name": "Peter",
}
]
This is the PHP code I have:
$url = 'http://urltotheapi';
$content = file_get_contents($url);
$json = json_decode($content, true);
解决方案
foreach($json as $i){
echo $i['name'];
}
这篇关于如何获得JSON数据在PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文