Oft hat man ein Array, welches Einträge mit einem Datum enthält. Wenn man das Array nach dem Datum sortieren will dann kann folgende Funktion helfen
<?php function sortArray($a,$b){ $timeA = explode('.',$a[3]); $timeB = explode('.',$b[3]); $timeA = mktime(0,0,0,$timeA[1],$timeA[0],$timeA[2]); $timeB = mktime(0,0,0,$timeB[1],$timeB[0],$timeB[2]); if($timeA == $timeB){ return 0; } return ($timeA<$timeB)?-1:1; } $str[0] = 'o|b|c|07.04.08|1'; $str[1] = 't|w|c|09.04.08|0'; $str[2] = 'u|b|z|10.04.08|0'; $str[3] = 'pp|bz|cu|02.04.08|1'; $arr = array(); foreach($str as $wert){ $arr[] = explode('|',$wert); } usort($arr,"sortArray"); echo '<pre>'; var_dump($arr); echo '</pre>'; ?>
<php> function sortArray($a,$b){
$timeA = explode('.',$a[3]);
$timeB = explode('.',$b[3]);
$timeA = mktime(0,0,0,$timeA[1],$timeA[0],$timeA[2]);
$timeB = mktime(0,0,0,$timeB[1],$timeB[0],$timeB[2]);
if($timeA == $timeB){
return 0;
}
return ($timeA<$timeB)?-1:1;
}
$str[0] = 'o|b|c|07.04.08|1'; $str[1] = 't|w|c|09.04.08|0'; $str[2] = 'u|b|z|10.04.08|0'; $str[3] = 'pp|bz|cu|02.04.08|1'; $arr = array(); foreach($str as $wert){
$arr[] = explode('|',$wert);
} usort($arr,„sortArray“); echo '<pre>'; var_dump($arr); echo '</pre>'; </php>
An unforeseen error has occured. This is most likely a bug somewhere. It might be a problem in the discussion plugin.
More info has been written to the DokuWiki error log.