php - Get a JSON value from an array using Laravel -


i trying latitude , longitude values json array - $response, returned google, geocoding services.

the json array returned such (random address):

{    "results":[       {          "address_components":[             {                "long_name":"57",                "short_name":"57",                "types":[                   "street_number"                ]             },             {                "long_name":"polo gardens",                "short_name":"polo gardens",                "types":[                   "route"                ]             },             {                "long_name":"bucksburn",                "short_name":"bucksburn",                "types":[                   "sublocality_level_1",                   "sublocality",                   "political"                ]             },             {                "long_name":"aberdeen",                "short_name":"aberdeen",                "types":[                   "locality",                   "political"                ]             },             {                "long_name":"aberdeen",                "short_name":"aberdeen",                "types":[                   "postal_town"                ]             },             {                "long_name":"aberdeen city",                "short_name":"aberdeen city",                "types":[                   "administrative_area_level_2",                   "political"                ]             },             {                "long_name":"united kingdom",                "short_name":"gb",                "types":[                   "country",                   "political"                ]             },             {                "long_name":"ab21 9ju",                "short_name":"ab21 9ju",                "types":[                   "postal_code"                ]             }          ],          "formatted_address":"57 polo gardens, aberdeen, aberdeen city ab21 9ju, uk",          "geometry":{             "location":{                "lat":57.1912463,                "lng":-2.1790257             },             "location_type":"rooftop",             "viewport":{                "northeast":{                   "lat":57.19259528029149,                   "lng":-2.177676719708498                },                "southwest":{                   "lat":57.18989731970849,                   "lng":-2.180374680291502                }             }          },          "partial_match":true,          "place_id":"chijltex1jqshegr5uj2dnc6n9s",          "types":[             "street_address"          ]       }    ],    "status":"ok" } 

i have tried following:

json_decode($response->results->geometry->location->lat) 

but returns 'trying access property of non-object'.

any hugely appreciated.

var_dump(json_decode($response)->results[0]->geometry->location->lat); 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -