Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing SimpleXML Object attribute

Have this print output from print_r($theobject);

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

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

Just cannot find a way to get element 0 which is "Abnormal psychology :"

Lets call the object as $theobject I did $theobject[0], didn't get anything.

Many Thanks

like image 561
porto alet Avatar asked Nov 27 '25 20:11

porto alet


1 Answers

You can just cast the object to a string:

$str = (string)$theobject;
like image 137
Greg Avatar answered Nov 30 '25 09:11

Greg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!