Exception or error:
i need to get ‘name’ ‘avl_bikes’ and ‘coordinates’ to show up to my php from this website http://data.foli.fi/citybike/smoove. My code currently looks like this
<?php
@ini_set("display_errors", 1);
@ini_set("error_reporting", E_ALL);
$string = file_get_contents("http://data.foli.fi/citybike/smoove");
$json_a = json_decode($string, true);
$aika = $json_a["name"]["avl_bikes"];
echo $aika;
?>
Thank you
How to solve:
You can access json decoded data as follows:-
$string = file_get_contents("http://data.foli.fi/citybike/smoove");
$json_a = json_decode($string, true);
foreach($json_a['result'] as $key => $res){
echo "avl_bikes = ".$res['avl_bikes']."<br>";
echo "Name = ".$res['name']."<br>";
echo "Coordinates = ".$res['coordinates']."<br>";
}