I tried to get data from a JSON file, but it didn't work the way I wanted it to.
Here's the JSON content:
{
"ok":true,
"license":"CC BY 4.0 - https:\/\/creativecommons.tankerkoenig.de",
"data":"MTS-K",
"status":"ok",
"stations":[
{
"id":"0d08b94c-6ece-4924-9c8a-205b971e9eff",
"name":"AVIA M\u00fcnsingen",
"brand":"AVIA",
"street":"Haupstr.",
"place":"M\u00fcnsingen",
"lat":48.411,
"lng":9.50876,
"dist":0.1,
"diesel":1.249,
"e5":1.369,
"e10":1.349,
"isOpen":true,
"houseNumber":"117",
"postCode":72525
}
]
}
Here's my code:
$url = "https://creativecommons.tankerkoenig.de/json/list.phplat=48.411&lng=9.508&rad=1&sort=dist&type=all&apikey=APIKEY";
$contents = file_get_contents($url);
$aviadiesel = json_decode($contents);
$preise = $aviadiesel->{'stations'};
echo $preise[diesel];
But with this code the Output looks like this:
Array
I would appreciate your help. I'm new to PHP, and Google couldn't help me as well so far.