troubleshooting Question

php object to array

Avatar of Robert Saylor
Robert SaylorFlag for United States of America asked on
PHP
7 Comments1 Solution95 ViewsLast Modified:
How to convert this object to array?

I am using geocoder-php/google-maps-provider php-http/guzzle6-adapter php-http/message to convert the city, state to lat/long. The result is shown below when I output with print_r

Need some help converting this to an array or walk me through the steps to collect the data from the result.

Geocoder\Model\AddressCollection Object
(
    [locations:Geocoder\Model\AddressCollection:private] => Array
        (
            [0] => Geocoder\Provider\GoogleMaps\Model\GoogleAddress Object
                (
                    [id:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => ChIJXYHEcBpN-IgRW6TZSPQKM7U
                    [locationType:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => APPROXIMATE
                    [resultType:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => Array
                        (
                            [0] => locality
                            [1] => political
                        )

                    [formattedAddress:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => Aiken, SC, USA
                    [streetAddress:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [intersection:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [political:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => United States
                    [colloquialArea:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [ward:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [neighborhood:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [premise:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [subpremise:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [naturalFeature:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [airport:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [park:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [pointOfInterest:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [establishment:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => 
                    [subLocalityLevels:Geocoder\Provider\GoogleMaps\Model\GoogleAddress:private] => Geocoder\Model\AdminLevelCollection Object
                        (
                            [adminLevels:Geocoder\Model\AdminLevelCollection:private] => Array
                                (
                                )

                        )

                    [coordinates:Geocoder\Model\Address:private] => Geocoder\Model\Coordinates Object
                        (
                            [latitude:Geocoder\Model\Coordinates:private] => 33.5604168
                            [longitude:Geocoder\Model\Coordinates:private] => -81.7195533
                        )

                    [bounds:Geocoder\Model\Address:private] => Geocoder\Model\Bounds Object
                        (
                            [south:Geocoder\Model\Bounds:private] => 33.471154
                            [west:Geocoder\Model\Bounds:private] => -81.7790329
                            [north:Geocoder\Model\Bounds:private] => 33.590592
                            [east:Geocoder\Model\Bounds:private] => -81.6720859
                        )

                    [streetNumber:Geocoder\Model\Address:private] => 
                    [streetName:Geocoder\Model\Address:private] => 
                    [subLocality:Geocoder\Model\Address:private] => 
                    [locality:Geocoder\Model\Address:private] => Aiken
                    [postalCode:Geocoder\Model\Address:private] => 
                    [adminLevels:Geocoder\Model\Address:private] => Geocoder\Model\AdminLevelCollection Object
                        (
                            [adminLevels:Geocoder\Model\AdminLevelCollection:private] => Array
                                (
                                    [1] => Geocoder\Model\AdminLevel Object
                                        (
                                            [level:Geocoder\Model\AdminLevel:private] => 1
                                            [name:Geocoder\Model\AdminLevel:private] => South Carolina
                                            [code:Geocoder\Model\AdminLevel:private] => SC
                                        )

                                    [2] => Geocoder\Model\AdminLevel Object
                                        (
                                            [level:Geocoder\Model\AdminLevel:private] => 2
                                            [name:Geocoder\Model\AdminLevel:private] => Aiken County
                                            [code:Geocoder\Model\AdminLevel:private] => Aiken County
                                        )

                                )

                        )

                    [country:Geocoder\Model\Address:private] => Geocoder\Model\Country Object
                        (
                            [name:Geocoder\Model\Country:private] => United States
                            [code:Geocoder\Model\Country:private] => US
                        )

                    [timezone:Geocoder\Model\Address:private] => 
                    [providedBy:Geocoder\Model\Address:private] => google_maps
                )

        )

)
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros