note 87890 added to function.array-multisort
| From: | Anonymous at osu1 dot php dot net | Date: | Mon, 29 Dec 2008 07:06:34 +0000 |
| Subject: | note 87890 added to function.array-multisort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148635@lists.php.net to get a copy of this message | ||
a example for my previous note:
1. crateing array $idol, print_r as:
Array
(
[0] => Array
(
[0] => 97/1/12
[1] => snoopy
)
[1] => Array
(
[0] => 97/1/1
[1] => doraemon
)
[2] => Array
(
[0] => 96/11/24
[1] => doraemon
)
2. creating 2 column-array: idol_name & idol_dob:
idol_name, print_r as =
Array
(
[0] => snoopy
[1] => doraemon
[2] => doraemon
)
idol_dob, print_r as =
Array
(
[0] => 97/1/12
[1] => 97/1/1
[2] => 96/11/24
)
3. I intend to do SQL's 'order by idol_name desc, idol_birth asc', so I issue
command:
array_multisort($idol_name, SORT_DESC,
$idol_dob, SORT_ASC,
$idol);
4. Since the manual said it will key the key association of arrays, I expect $idol becomes this:
Array
(
[0] => Array
(
[0] => 97/1/12
[1] => snoopy
)
[2] => Array
(
[0] => 96/11/24
[1] => doraemon
)
[1] => Array
(
[0] => 97/1/1
[1] => doraemon
)
)
5. However, it prints out this:
Array
(
[0] => Array
(
[0] => 97/1/12
[1] => snoopy
)
[1] => Array
(
[0] => 96/11/24
[1] => doraemon
)
[2] => Array
(
[0] => 97/1/1
[1] => doraemon
)
)
6. note the key association of $idol, there're reassigned!
What's wrong with the manual? or what's wrong with my understanding?
----
Server IP: 140.113.54.119
Probable Submitter: 211.20.177.117
----
Manual Page -- http://www.php.net/manual/en/function.array-multisort.php
Edit -- https://master.php.net/note/edit/87890
Del: integrated -- https://master.php.net/note/delete/87890/integrated
Del: useless -- https://master.php.net/note/delete/87890/useless
Del: bad code -- https://master.php.net/note/delete/87890/bad+code
Del: spam -- https://master.php.net/note/delete/87890/spam
Del: non-english -- https://master.php.net/note/delete/87890/non-english
Del: in docs -- https://master.php.net/note/delete/87890/in+docs
Del: other reasons-- https://master.php.net/note/delete/87890
Reject -- https://master.php.net/note/reject/87890
Search -- https://master.php.net/manage/user-notes.php