Let's say my JSON is this:
{
"achievement": [
{
"title": "All Around Submitter",
"description": "Get one piece of content approved in all six areas.",
"xp": 500,
"level_req": 1
},
{
"title": "World-wide Photo Journalist",
"description": "Get one photo approved in all six areas.",
"xp": 500,
"level_req": 1
},
{
"title": "Ready for Work",
"description": "Sign up and get validated",
"xp": 50,
"level_req": 1
},
{
"title": "Asian Pride",
"description": "Get ten pieces of content approved to a club in an Asian nation.",
"xp": 1500,
"level_req": 1
}
]
}
and my PHP code is this, so I load through that json file...:
<?php
$string = file_get_contents("achievements.json");
$json_a=json_decode($string,true);
foreach ($json_a as $key => $value){
echo $value[0]['title'] . " <br />";
}
?>
However it only out puts the first array. I know. Only 1. But what about the foreach
loop? Why isn't it loop for each row?