note 19856 added to function.array-multisort
| From: | richard at richardhayes dot net | Date: | Wed, 13 Mar 2002 11:33:27 +0000 |
| Subject: | note 19856 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27716@lists.php.net to get a copy of this message | ||
EXAMPLE: You have two arrays where one has results from a test and the other names of the
participants and you need to graph these results in descending order, but keeping the name and score
relationship in tact.
<?
$scores=array(90, 10, 70, 100);
$participants=array("liam","val","john","richard");
array_multisort($scores,SORT_DESC,$participants);
# would now produce:
# $scores[0]=100; $participants[0]="richard";
# $scores[1]=90; $participants[1]="liam";
# etc..
?>
--
http://www.php.net/manual/en/function.array-multisort.php
http://master.php.net/manage/user-notes.php?action=edit+19856
http://master.php.net/manage/user-notes.php?action=delete+19856
http://master.php.net/manage/user-notes.php?action=reject+19856