note 90598 added to function.usort
| From: | nospam at cirello dot org | Date: | Wed, 29 Apr 2009 19:18:33 +0000 |
| Subject: | note 90598 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154022@lists.php.net to get a copy of this message | ||
$arr = Array(
'1111' => Array('a' => 4, 'b' => 2),
'1211' => Array('a' => 2, 'b' => 2),
'1121' => Array('a' => 2, 'b' => 2),
'3211' => Array('a' => 1, 'b' => 2)
);
print_r($arr);
function uasort_idx(&$arr, $idx){
uasort($arr, create_function('$a, $b', '
if($a["'.$idx.'"] == $b["'.$idx.'"]){
return 0;
}
return(($a["'.$idx.'"] < $b["'.$idx.'"])?-1:1);
'));
}
uasort_idx($arr, 'a');
print_r($arr);
----
Server IP: 200.185.126.110
Probable Submitter: 200.213.210.2
----
Manual Page -- http://www.php.net/manual/en/function.usort.php
Edit -- https://master.php.net/note/edit/90598
Del: integrated -- https://master.php.net/note/delete/90598/integrated
Del: useless -- https://master.php.net/note/delete/90598/useless
Del: bad code -- https://master.php.net/note/delete/90598/bad+code
Del: spam -- https://master.php.net/note/delete/90598/spam
Del: non-english -- https://master.php.net/note/delete/90598/non-english
Del: in docs -- https://master.php.net/note/delete/90598/in+docs
Del: other reasons-- https://master.php.net/note/delete/90598
Reject -- https://master.php.net/note/reject/90598
Search -- https://master.php.net/manage/user-notes.php