Forum Moderators: coopster

Message Too Old, No Replies

How to get the value of an object

         

DeezerD

6:08 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



Hi there

I have an object called $foo that returns the following value when I do print_r($foo) - it's an xml feed

I would like to get the value of href in the second array without having to process a loop on the whole object but I don't know how to do that

I tried with echo $object->['href'] but it returns the value of href in the first array

Do I have to make a loop on the whole array with something like 'give the value of [href] if [rel] value = enclosure?
Thanks for your help, here the result of print_r($object)

SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => alternate
[type] => text/xhtml
[title] => Title
[href] => /mapage/toto
)

)
SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => enclosure
[title] => Title
[width] => 384
[height] => 288
[href] => http://www.example.com/swf/2W7qlUF4jTKH
[type] => application/x-shockwave-flash
)

)

[edited by: eelixduppy at 6:09 pm (utc) on Aug. 27, 2007]
[edit reason] use example (delinked) [/edit]

eelixduppy

2:33 pm on Aug 30, 2007 (gmt 0)



Try something like this:

echo $foo->attributes[1]->url;