Hallo zusammen,
ich weiß einfach nicht, wie ich auf Daten in einer JSON-Datei richtig zugreifen kann. Zum Beispiel so eine Datei hier:
Da kann ich mit
auf die Werte lat und lng zugreifen.
Soweit so logisch.
Aber wie komme ich beispielsweise an den Straßennamen "route" unter "adress-compontents". Mit welchem Befehl, kann ich diese Variable auslesen?
Danke für Eure Hilfe!
ich weiß einfach nicht, wie ich auf Daten in einer JSON-Datei richtig zugreifen kann. Zum Beispiel so eine Datei hier:
Code:
{ "results" : [ { "address_components" : [ { "long_name" : "1600", "short_name" : "1600", "types" : [ "street_number" ] }, { "long_name" : "Amphitheatre Pkwy", "short_name" : "Amphitheatre Pkwy", "types" : [ "route" ] }, { "long_name" : "Mountain View", "short_name" : "Mountain View", "types" : [ "locality", "political" ] }, { "long_name" : "Santa Clara", "short_name" : "Santa Clara", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "California", "short_name" : "CA", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] }, { "long_name" : "94043", "short_name" : "94043", "types" : [ "postal_code" ] } ], "formatted_address" : "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA", "geometry" : { "location" : { "lat" : 37.42291810, "lng" : -122.08542120 }, "location_type" : "ROOFTOP", "viewport" : { "northeast" : { "lat" : 37.42426708029149, "lng" : -122.0840722197085 }, "southwest" : { "lat" : 37.42156911970850, "lng" : -122.0867701802915 } } }, "types" : [ "street_address" ] } ], "status" : "OK" }
PHP-Code:
$latitude = $output->results[0]->geometry->location->lat;
$longitude = $output->results[0]->geometry->location->lng;
Soweit so logisch.
Aber wie komme ich beispielsweise an den Straßennamen "route" unter "adress-compontents". Mit welchem Befehl, kann ich diese Variable auslesen?
Danke für Eure Hilfe!
Kommentar