note 100961 added to function.uasort
| From: | yannick dot battail at gmail dot com | Date: | Wed, 17 Nov 2010 14:37:32 +0000 |
| Subject: | note 100961 added to function.uasort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174122@lists.php.net to get a copy of this message | ||
An Example using anonymous function.
Anonymous functions make some time the code easier to understand.
<?php
$fruits =
array('Orange9','Orange11','Orange10','Orange6','Orange15');
uasort ( $fruits , function ($a, $b) {
return strnatcmp($a,$b); // or other function/code
}
);
print_r($fruits);
?>
returns
Array
(
[3] => Orange6
[0] => Orange9
[2] => Orange10
[1] => Orange11
[4] => Orange15
)
----
Server IP: 64.71.164.2
Probable Submitter: 149.5.216.46
----
Manual Page -- http://www.php.net/manual/en/function.uasort.php
Edit -- https://master.php.net/note/edit/100961
Del: integrated -- https://master.php.net/note/delete/100961/integrated
Del: useless -- https://master.php.net/note/delete/100961/useless
Del: bad code -- https://master.php.net/note/delete/100961/bad+code
Del: spam -- https://master.php.net/note/delete/100961/spam
Del: non-english -- https://master.php.net/note/delete/100961/non-english
Del: in docs -- https://master.php.net/note/delete/100961/in+docs
Del: other reasons-- https://master.php.net/note/delete/100961
Reject -- https://master.php.net/note/reject/100961
Search -- https://master.php.net/manage/user-notes.php