Re: Object Array?

From: Date: Thu, 18 May 2006 19:10:20 +0000
Subject: Re: Object Array?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236419@lists.php.net to get a copy of this message
Jay Paulson wrote:
I have an object from using simpleXML and inside that object is an array holding even more objects. However, it's not acting like an array and therefore I can't go through it. (i.e. I can't use the count function to see how big it is and loop through it) This below should be an array: $xml->RES->R When I use print_r($xml->RES) I get the below. As you can see [R] => Array but yet in the above example it is an object. I'm so confused and lost. Can anyone help? PHP version 5.0.4 SimpleXMLElement Object (
    [M] => 2010
<snip>
    [R] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [U] => http://.../benefits/
<snip>>
                )
            [1] => SimpleXMLElement Object
                (
                    [U] => http://.../benefits/benefits_websites.html
<snip>>                 )
            [2] => SimpleXMLElement Object
                (
                    [U] => http://www..com/jobs//benefits.html
You are right: $xml->RES->R is an array. If it doesn't act like an array, you might try assigning it to a new variable. Maybe something like this: $MyArray = $xml->RES->R; print_r($MyArray); Others might have better ideas. Keep trying. --J

« previous php.general (#236419) next »