如何使用PHP从JSON对象获取数据?
[ { "name": "Anders", }, { "name": "Chris", }, { "name": "Peter", } ]
这是我拥有的PHP代码:
$url = 'http://urltotheapi'; $content = file_get_contents($url); $json = json_decode($content, true);
foreach($json as $i){ echo $i[‘name’]; }