Re: Object Array?

From: Date: Thu, 18 May 2006 19:34:06 +0000
Subject: Re: Object Array?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236425@lists.php.net to get a copy of this message
>> 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] => ×k’�Ø …< >>  *¨fæ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 I've tried that even going so far as doing: $MyArray = array(); $MyArray = $xml->RES-R print_r($MyArray); I still run into the same problem. Hm. jay

« previous php.general (#236425) next »