Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Sorting a loop by date

$
0
0
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']; 
 
}
 

Viewing all articles
Browse latest Browse all 13200

Trending Articles