0

I have being trying to access variables in an output array produced by API and I cannot seem to get it, I am hours deep trying everything I can find and for the life of me I cannot seem to access it!

Array ( [data] => Array ( [0] => Array ( [latitude] => 53.268074 [longitude] => -109.99477 [type] => address [name] => 4529 33 Street [number] => 4529 [postal_code] => [street] => 33 Street [confidence] => 1 [region] => Saskatchewan [region_code] => SK [county] => Division No. 17 [locality] => Lloydminster [administrative_area] => [neighbourhood] => [country] => Canada [country_code] => CAN [continent] => North America [label] => 4529 33 Street, Lloydminster, SK, Canada ) ) )

I just want the 'latitude' and 'longitude' in their own php variable. Seems simple, but I have tried everything.

  • 1
    Does this answer your question? [How can I access an array/object?](https://stackoverflow.com/questions/30680938/how-can-i-access-an-array-object). This will help you understand the principles involved, and how to understand your data structure. – ADyson Oct 14 '22 at 15:55
  • `$latitude = $array['data'][0]['latitude'];` – Markus Zeller Oct 14 '22 at 15:56
  • You are accessing an object within two dimension array so trr like this: `echo $array['data'][0]->latitude;` – Abdullah Afridi Oct 14 '22 at 16:10

0 Answers0