note 31407 added to function.array-multisort
| From: | Andreas at rack1 dot php dot net | Date: | Mon, 21 Apr 2003 00:20:10 +0000 |
| Subject: | note 31407 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46863@lists.php.net to get a copy of this message | ||
I want to rearrange the following Stringstructure with array_multisort:
<?
# Before:
$string = "2-3-60065|5-1-20053|8-2-60512|1-1-35421|4-2-99241|7-3-18152";
$array1 = explode("|",$string);
foreach($array1 as $value){
list($a,$b,$c) = explode("-",$value);
$array2[$a][0]=$b;
$array2[$a][1]=$c;
}
# array_multisort(???);
# After multisort
$string2 = "7-3-18152|5-1-20053|1-1-35421|2-3-60065|8-2-60512|4-2-99241";
?>
I hope you can see, that I want to sort by the 3rd element of each subarray...
--
http://www.php.net/manual/en/function.array-multisort.php
http://master.php.net/manage/user-notes.php?action=edit+31407
http://master.php.net/manage/user-notes.php?action=delete+31407
http://master.php.net/manage/user-notes.php?action=reject+31407