home

Search A2Z 24

Get value from SimpleXMLElement Object

X
SimpleXMLElement Object
(
    [code] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [postalcode] => 01-935
                    [name] => Warszawa
                    [countryCode] => PL
                    [lat] => 52.25
                    [lng] => 21.0
                    [adminCode1] => SimpleXMLElement Object
                        (
                        )

                    [adminName1] => Mazowieckie
                    [adminCode2] => SimpleXMLElement Object
                        (
                        )

                    [adminName2] => Warszawa
                    [adminCode3] => SimpleXMLElement Object
                        (
                        )

                    [adminName3] => SimpleXMLElement Object
                        (
                        )

                    [distance] => 0.0
                )

I do as you can see $xml->code[0]->lat and it returns an object. How can i get the value?

About Author

Share your thoughts!

Login as a member to access comment posting block !! click-here

Thoughts From Other Users (1)

Dispalying 1 to 1 of 1 |
You have to cast simpleXML Object to a string.
$value = (string) $xml->code[0]->lat;
 
Posted 10 Years ago | See All Reply (0) | Reply
Dispalying 1 to 1 of 1 |

×