note 17610 added to function.array-multisort
| From: | php-general at lists dot php dot net | Date: | Mon, 17 Dec 2001 05:27:06 +0000 |
| Subject: | note 17610 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-22965@lists.php.net to get a copy of this message | ||
/***********************************************************
* Please don't just look at this code, TRY IT! It will be
* much clearer if you try it and play with it
***********************************************************
* This code is meant to demo how this function actually
* works and help clear up some confusion about how and
* what array_multisort does I am posting this because
* I was confused about it too, and almost filed a bug
* report
***********************************************************
* To use this code, just replace "...." with either a
* tab or 4 spaces.
***********************************************************
*/
$testArray = array(
....array('e', 'g', 'a', 'c', 'l'),
....array('0', '1', '2', '3', '4'),
....array('5', '6', '7', '8', '9')
);
echo "<hr>Before Sorting:";
printArray($testArray);
array_multisort(
....$testArray[0],
....$testArray[1],
....$testArray[2]
);
echo "After Sorting:";
printArray($testArray);
function printArray($ar) {
....echo '<table border=1 cellpadding=2 cellspacing=2><tr>';
....foreach ($ar as $innerArray) {
........echo '<td>';
........foreach ($innerArray as $data) {
............echo "$data<hr>";
........}
........echo '</td>';
....}
....echo '</tr></table><hr>';
}
--
http://www.php.net/manual/en/function.array-multisort.php
http://master.php.net/manage/user-notes.php?action=edit+17610
http://master.php.net/manage/user-notes.php?action=delete+17610
http://master.php.net/manage/user-notes.php?action=reject+17610