note 90793 deleted from function.array-multisort by danbrown
| From: | danbrown@php.net | Date: | Sun, 10 May 2009 21:41:04 +0000 |
| Subject: | note 90793 deleted from function.array-multisort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154425@lists.php.net to get a copy of this message | ||
Note Submitter: mail at sport07 dot de
----
Here is a small sniplet for sorting a 2-dimensional array in php.
function MultiSortieren($Daten,$Feld1,$Feld2)
{
$Anzahl=count($Daten);
For($y=0;$y<$Anzahl;$y++){
for($z=$y+1;$z<=$Anzahl;$z++){
if($Daten[$y][$Feld1]<$Daten[$z][$Feld1]){
$Test=$Daten[$y];
$Daten[$y]=$Daten[$z];
$Daten[$z]=$Test;
}else{
if($Daten[$y][$Feld1]==$Daten[$z][$Feld1]){
if($Daten[$y][$Feld2]>$Daten[$z][$Feld2]){
$Test=$Daten[$y];
$Daten[$y]=$Daten[$z];
$Daten[$z]=$Test;
}
}
}
}
}
return $Daten;
}
It sorts a Array ($Daten) in order of $Feld1 and then $Feld2
----------
http://www.sport07.de/code.php