I have this source file.
[
{
"title": "Course1",
"location": "BuildingA",
"day": "wednesday",
"id": 85412
},
{
"title": "Course2",
"location": "BuidlingB",
"day": "friday",
"id": 85413
},
{
"title": "Course3",
"location": "BuidlingA",
"day": "friday",
"id": 85414
}
]
How can I, in PHP, print only the values of the keys ‘title’ and ‘location’?
The code I’ve got so far is:
$array = json_decode($json, true);
foreach ($array as $key => $jsons) {
foreach($jsons as $key => $value)
echo $value." ";
}
1 Answer