note 44690 added to function.array-multisort
| From: | FrancoisA dot at osu1 dot php dot net | Date: | Fri, 13 Aug 2004 00:39:31 +0000 |
| Subject: | note 44690 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74569@lists.php.net to get a copy of this message | ||
//This WORKS, and this is SIMPLE.
$products[0][price] = 2;
$products[0][name] = "b";
$products[0][cat] = "good";
$products[0][options][1] = 2;
$products[0][options][2] = 3;
$products[1][price] = 4.78;
$products[1][name] = "a";
$products[1][cat] = "bad";
$products[2][price] = 1.85;
$products[2][name] = "c";
$products[2][cat] = "good";
$products[2][options][1] = 2;
$products[2][options][2] = 3;
// Sort by price
foreach ($products as $row) $sortArray[] = $row[price];
array_multisort($sortArray, $prod);
// Note that array_multisort($sortArray, $prod) WORKS
// and array_multisort($prod, $sortArray) WILL NOT WORK
// Don't mix it up, test it
// Print out the results
print_r($prod);
----
Manual Page -- http://www.php.net/manual/en/function.array-multisort.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44690
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44690&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44690&report=yes
Search -- http://master.php.net/manage/user-notes.php