note 83701 added to function.uasort
| From: | phparobasekochiraperiodcom at osu1 dot php dot net | Date: | Sun, 08 Jun 2008 11:13:44 +0000 |
| Subject: | note 83701 added to function.uasort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140236@lists.php.net to get a copy of this message | ||
Difference between uasort() and usort(), the missing example ...
<?php
$arr = array ( 10 => array('id' => 'dix', 'aa' =>
'1010'),
100 => array('id' => 'cent', 'aa' =>
'100100'),
2 => array('id' => 'deux', 'aa' =>
'22'),
7 => array('id' => 'sept', 'aa' =>
'77'));
// id sorting
function so ($a, $b) { return (strcmp ($a['id'],$b['id'])); }
?>
*** uasort($arr, 'so') output:
<?php Array (
[100] => Array
(
[id] => cent
[aa] => 100100
)
[2] => Array
(
[id] => deux
[aa] => 22
)
[10] => Array
(
[id] => dix
[aa] => 1010
)
[7] => Array
(
[id] => sept
[aa] => 77
))?>
*** usort($arr, 'so') output:
<?php Array (
[0] => Array
(
[id] => cent
[aa] => 100100
)
[1] => Array
(
[id] => deux
[aa] => 22
)
[2] => Array
(
[id] => dix
[aa] => 1010
)
[3] => Array
(
[id] => sept
[aa] => 77
))?>
----
Server IP: 61.195.146.164
Probable Submitter: 218.219.209.195
----
Manual Page -- http://www.php.net/manual/en/function.uasort.php
Edit -- https://master.php.net/note/edit/83701
Del: integrated -- https://master.php.net/note/delete/83701/integrated
Del: useless -- https://master.php.net/note/delete/83701/useless
Del: bad code -- https://master.php.net/note/delete/83701/bad+code
Del: spam -- https://master.php.net/note/delete/83701/spam
Del: non-english -- https://master.php.net/note/delete/83701/non-english
Del: in docs -- https://master.php.net/note/delete/83701/in+docs
Del: other reasons-- https://master.php.net/note/delete/83701
Reject -- https://master.php.net/note/reject/83701
Search -- https://master.php.net/manage/user-notes.php