首先,true
在json_decode()
函数中传递第二个参数,以将解码后的数据作为数组获取。然后,使用如下所示的简单foreach
循环:
$json = file_get_contents('http://api.fixer.io/latest');
$data = json_decode($json, true);
foreach($data['rates'] as $currency => $value){
echo $currency . " => " . $value . '<br />';
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句