hi there,
i've got a problem with the 3rd party webservices that i'm using in that they are pretty rigid in how they can be used... for example they don't allow me to return a section of the search results or to specify the order of search results etc.
anyhow i am in the position where i have a simpleXML object that in turn contains an array of simpleXML objects returned from the webservice. what i need to be able to do is reverse this array of objects, in a quick and neat manner. i know that i could serialise each object, put that into an array then reverse it but that is going to be costly in terms of time and processing.
i assumed i could just use php's native reverse_array function on the DataRow attribute of the parent object, i.e.
$events->DataRow=array_reverse($events->DataRow);
(as i do with normal arrays) but it doesn't like this and i get the following errors:
"Warning: array_reverse() [function.array-reverse]: The argument should be an array in <blah blah>.inc.php on line 162
Warning: main() [function.main]: Cannot assign to an array of nodes (duplicate subnodes or attr detected) in <blah blah>.inc.php on line 162"
the object structure from a print_r is as below:
SimpleXMLElement Object
(
[DataRow] => Array
(
[0] => SimpleXMLElement Object
( etc....
any help on this would be super-appreciated, as the webservices are kind of slow as they are thus i've no leeway in terms of time/processing expenditure so need an elegant solution!
best,
rob ganly
simpleXML object problem
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Code: Select all
for($i=count($node)-1;$i>=0;$i--){
// do somthing with $node[$i];
}