Reputation: 1477
im trying to extract the data inside the json file, but its not working, here is my code:
JSON:
{
"list":[
{
"key":"12 ano",
"value":"12 ano"
},
{
"key":"12 ano administrativo",
"value":"12 ano administrativo"
},
{
"key":"12 ano contabilidade",
"value":"12 ano contabilidade"
}
]
}
PHP:
$url = 'what.json';
$content = file_get_contents($url);
$json = json_decode($content, true);
foreach($json as $i){
echo $i['value'];
}
Upvotes: 1
Views: 92
Reputation: 444
You must call to $json['list']
in your foreach because without it, it will make a loop on the primary array that only contain the list array.
Upvotes: 1