note 25659 added to function.array-multisort

From: Date: Tue, 01 Oct 2002 19:16:39 +0000
Subject: note 25659 added to function.array-multisort
Groups: php.notes 
Request: Send a blank email to php-notes+get-37480@lists.php.net to get a copy of this message
My problem: query1 SELECT DISTINCT(ref) FROM $login WHERE ids LIKE '$what' 2nd query: SELECT count(ref) FROM $login WHERE ids LIKE '$what' AND ref LIKE '$query1 In 1st query I ask mysql to give me unique ref values. In 2nd query I am asking db to show me how many times each unique ref You can put it in 2dimension array. Array[how_many][ref_name] I try to order this.... problem. Let's do one dimension array query1.";".query2 Now we have array like this array[0]="3;http://yahoo.com" array[1]="7;http://not.yahoo.com" Now we can use array_multisort array_multisort($array,SORT_NUMERIC, SORT_DESC); Now we have sorted array. all you need now is to use explode() function. -- http://www.php.net/manual/en/function.array-multisort.php http://master.php.net/manage/user-notes.php?action=edit+25659 http://master.php.net/manage/user-notes.php?action=delete+25659 http://master.php.net/manage/user-notes.php?action=reject+25659

« previous php.notes (#37480) next »