denhamd2 Posted August 19, 2013 Share Posted August 19, 2013 Hi, I'm using Simple XML to read from an XML file. I've done a loop for each event. It gives me all the events back in the order of the XML file. However, instead I am trying to sort events by date. Any idea how I could do this? Please see my code below. FYI, the date and time is in UTC timestamp format (eg. 1377361800) Thanks in advance for your help. $newresult = $result->xpath("//match/matchname[.='$uniqueteam']/.."); foreach ($newresult as $newmatchlist) { $newmatch = trim($newmatchlist->{'matchname'}[0]); $sport = $newmatchlist->{'sportname'}[0]; $tournament = $newmatchlist->{'tournamentname'}[0]; $time=$newmatchlist->{'matchname'}[0]['dateandtime']; } Link to comment https://forums.phpfreaks.com/topic/281349-sorting-a-loop-by-date/ Share on other sites More sharing options...
cyberRobot Posted August 19, 2013 Share Posted August 19, 2013 Have you tried storing the information as a multi-dimensional array and then using array_multisort()? Example 3 from the following link seems like it would work: http://php.net/manual/en/function.array-multisort.php Link to comment https://forums.phpfreaks.com/topic/281349-sorting-a-loop-by-date/#findComment-1445794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.