I have a variable $foo with this content:
object(SimpleXMLElement)#969 (2) {
["@attributes"]=>
array(1) {
["type"]=>
string(4) "html"
}
[0]=>
string(13) "Viernes Santo"
}
I’m trying to get the content “Viernes Santo” but I can’t..I tried $foo[0] but that returns the same content..any idea?
The SimpleXMLElement behaves like an object which is why people get confused like you did, but it’s actually a language construct which is a little different. The elements and their data must be typecast to the data type you want to work with because by default everything returned from a SimpleXMLElement function is a SimpleXMLElement which if not typecast by a function, must be directly typecast.
If you call: