Jump to content

Sorting a loop by date


denhamd2

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.