I was doing tests to understand how to correctly handle the data obtained from a file Json
and I find the following:
Json
:
{
"rates": {
"AED": 3.673014,
"AFN": 68.343295,
"ALL": 115.9367,
"AMD": 479.122298
}
if I do this
$urlapi=file_get_contents('urljson');
$data = json_decode($urlapi,true);
var_dump($data['rates']['AFN']);
shows me one in particular, I imagine that in this case I can solve it with a foreach
, more or less:
foreach ($data as $precios) {
print_r($data['rates'][?????]);
}
But there I should modify the subscript so that as long as I have elements I show each value, instead of the AFN that lists all, can you explain how it is done correctly? I would like you to show me each value and I can not find it back.
Thank you!