I am trying to output some json data from a json file via php but it does not seem to work. I tried this:
<?php
$jsonFile = file_get_contents('dataset/dataset.json');
$data = json_decode($jsonFile, true);
echo $data->{'data'}[0]->{'letter'}
?>
The json file is following:
{
"data":[
{
"letter":"A",
"blocks":{
"1":"0",
"2":"0",
"3":"0",
"4":"0",
"5":"0"
}
}
]}
Basically it should output the letter "A" but it outputs nothing. What did I do wrong? Thanks
P.S. I tried to do it like here: How to process JSON in PHP? but it does not work.