Re: Object Array?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux