Mute Posted February 28, 2007 Share Posted February 28, 2007 Hi, I'm parsing some XML and then spitting it out on the screen. What I'd like to be able to do is reverse the array that SimpleXML creates but for the life of me, I can't do it. Here's some sample XML. <league> <country>England</country> <name>Premier League</name> <all_matches> <item> <round>1</round> <date>19 Aug 06</date> <result>1 - 1</result> <team1>Sheffield Utd.</team1> <team2>Liverpool</team2> </item> <item> <round>1</round> <date>19 Aug 06</date> <result>3 - 1</result> <team1>West Ham United</team1> <team2>Charlton</team2> </item> <item> <round>1</round> <date>19 Aug 06</date> <result>1 - 1</result> <team1>Arsenal</team1> <team2>Aston Villa</team2> </item> </allmatches> </league> I'd like to be able to show the <item> tags in reverse. Link to comment https://forums.phpfreaks.com/topic/40484-simplexml-reverse/ Share on other sites More sharing options...
Barand Posted February 28, 2007 Share Posted February 28, 2007 try <?php $xml = simplexml_load_file('league.xml'); foreach ($xml->all_matches->item as $item) { $a[]=$item ; } $a = array_reverse($a); echo '<pre>', print_r($a, true), '</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/40484-simplexml-reverse/#findComment-195886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.