note 10119 added to array_multisort
| From: | e dot deal at asmis dot net | Date: | Thu, 14 Dec 2000 11:05:27 +0000 |
| Subject: | note 10119 added to array_multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8727@lists.php.net to get a copy of this message | ||
attention, si une case d'un tableau à 2 dimension ne contient rien, alors le tri se fait mal
exemple:
$TAB[0][0]="TOTO";
$TAB[1][0]="toto";
$TAB[0][1]="TITI";
$TAB[1][1]="titi";
$TAB[0][2]="TATA";
$TAB[1][2]="";
reset($TAB);
while (list($i,$val)=each($TAB)){
while (list($j,$vale)=each($TAB[$i])) echo "TAB[$i][$j]=$vale <br>";
}
echo "----<br>";
array_multisort ($TAB[0],SORT_ASC ) ;
reset($TAB);
while (list($i,$val)=each($TAB)){
while (list($j,$vale)=each($TAB[$i])) echo "TAB[$i][$j]=$vale <br>";
}
Ce qui donne l'affichage:
TAB[0][0]=TOTO
TAB[0][1]=TITI
TAB[0][2]=TATA
TAB[1][0]=toto
TAB[1][1]=titi
TAB[1][2]=
----
TAB[0][0]=TATA
TAB[0][1]=TITI
TAB[0][2]=TOTO
TAB[1][0]=toto
TAB[1][1]=titi
TAB[1][2]=
http://www.php.net/manual/fr/function.array-multisort.php