Accessing a SimpleXML Object Attribute

Enter this print output print_r($theobject);

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [label] => a
        )

    [0] => Abnormal psychology : Abnormal psychology :
)

I just can’t find a way to get element 0, which is "Abnormal Psychology:"

Allows you to call an object as $theobject I did $theobject[0], received nothing.

Many thanks

+3
source share
1 answer

You can simply pass the object to a string:

$str = (string)$theobject;
+4
source

Source: https://habr.com/ru/post/1720647/


All Articles