Wie überprüfe ich, ob ein Nachbarschaftswert im Objekt vorhanden ist?Prüfen, ob Wert im Objekt vorhanden ist
{
"results" : [
{
"address_components" : [
{
"long_name" : "2900",
"short_name" : "2900",
"types" : [ "street_number" ]
},
{
"long_name" : "Ranch Road 620 North",
"short_name" : "Ranch Rd 620 N",
"types" : [ "route" ]
},
{
"long_name" : "Villas On Travis",
"short_name" : "Villas On Travis",
"types" : [ "neighborhood", "political" ]
},
{
"long_name" : "Austin",
"short_name" : "Austin",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Travis County",
"short_name" : "Travis County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Texas",
"short_name" : "TX",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "78734",
"short_name" : "78734",
"types" : [ "postal_code" ]
},
{
"long_name" : "2209",
"short_name" : "2209",
"types" : [ "postal_code_suffix" ]
}
]
}
]
}
Ich habe versucht
if ($jsonarray->results[0]->address_components[2]->types == 'neighborhood') {
$neighborhood = $jsonarray->results[0]->address_components[2]->long_name;
}
überall in dem Objekt oder an einem bestimmten Ort? –
Typen ist immer noch ein Array, also müssen Sie nicht sagen, Typen [0] – Rob85
Es gibt nur einen Ort: https://maps.googleapis.com/maps/api/geocode/json?atlnng=30.560030000000,-97.691430000000 – santa