note 91802 added to function.usort
| From: | majkl578 at gmail dot com | Date: | Fri, 26 Jun 2009 00:25:34 +0000 |
| Subject: | note 91802 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157514@lists.php.net to get a copy of this message | ||
As of PHP 5.3 it is possible to use anonymous functions:
<?php
$arrayToSort = array(2,6,1,9,3);
/* As of PHP 5.3 */
usort($arrayToSort, function($a, $b) {
return $a > $b ? 1 : -1;
});
var_dump($arrayToSort);
/* Returns:
array
0 => int 1
1 => int 2
2 => int 3
3 => int 6
4 => int 9
*/
?>
----
Server IP: 147.32.160.17
Probable Submitter: 85.70.87.186
----
Manual Page -- http://www.php.net/manual/en/function.usort.php
Edit -- https://master.php.net/note/edit/91802
Del: integrated -- https://master.php.net/note/delete/91802/integrated
Del: useless -- https://master.php.net/note/delete/91802/useless
Del: bad code -- https://master.php.net/note/delete/91802/bad+code
Del: spam -- https://master.php.net/note/delete/91802/spam
Del: non-english -- https://master.php.net/note/delete/91802/non-english
Del: in docs -- https://master.php.net/note/delete/91802/in+docs
Del: other reasons-- https://master.php.net/note/delete/91802
Reject -- https://master.php.net/note/reject/91802
Search -- https://master.php.net/manage/user-notes.php