PHP expert |
|
<?php
$xml = new SimpleXMLElement($xml_string);
$count = count($xml->website);
for( $i = 0 ; $i < $count ; $i++ ) {
$expI = explode("-" , $xml->website[$i]->episode[0]->publish_date);
$publish_time_i = mktime(0,0,0,$expI[1] , $expI[2] , $expI[0]);
for( $j = $i+1 ; $j < $count ; $j++ ) {
$expJ = explode("-" , $xml->website[$j]->episode[0]->publish_date);
$publish_time_j = mktime(0,0,0,$expJ[1] , $expJ[2] , $expJ[0]);
if( $publish_time_i < $publish_time_j ) {
$tmp = $xml->website[$i];
$xml->website[$i] = $xml->website[$j];
$xml->website[$j] = $tmp;
}
}
}
<?php $xml = new SimpleXMLElement($xml_string); $count = count($xml->website); for( $i = 0 ; $i < $count ; $i++ ) { $expI = explode("-" , $xml->website[$i]->episode[0]->publish_date); $publish_time_i = mktime(0,0,0,$expI[1] , $expI[2] , $expI[0]); for( $j = $i+1 ; $j < $count ; $j++ ) { $expJ = explode("-" , $xml->website[$j]->episode[0]->publish_date); $publish_time_j = mktime(0,0,0,$expJ[1] , $expJ[2] , $expJ[0]); if( $publish_time_i < $publish_time_j ) { $tmp = $xml->website[$i]; $xml->website[$i] = $xml->website[$j]; $xml->website[$j] = $tmp; } } }
Heb het niet getest maar zo zou het er ongeveer uit moeten zien. Het is best om simpleXML te gebruiken. |