note 97397 added to function.usort
| From: | AlexRath at osu1 dot php dot net | Date: | Sat, 17 Apr 2010 18:35:51 +0000 |
| Subject: | note 97397 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168354@lists.php.net to get a copy of this message | ||
This is the perfect Place for anonymous Functions, here an Example:
<?php
$array = array(3, 2, 5, 6, 1);
usort($array, function($func_a, $func_b) {
if($func_a == $func_b) return 0;
return ($func_a < $func_b) ? -1 : 1;
});
foreach ($array as $key => $value) echo "$key: $value\n";
?>
----
Server IP: 69.147.83.197
Probable Submitter: 84.166.11.75
----
Manual Page -- http://www.php.net/manual/en/function.usort.php
Edit -- https://master.php.net/note/edit/97397
Del: integrated -- https://master.php.net/note/delete/97397/integrated
Del: useless -- https://master.php.net/note/delete/97397/useless
Del: bad code -- https://master.php.net/note/delete/97397/bad+code
Del: spam -- https://master.php.net/note/delete/97397/spam
Del: non-english -- https://master.php.net/note/delete/97397/non-english
Del: in docs -- https://master.php.net/note/delete/97397/in+docs
Del: other reasons-- https://master.php.net/note/delete/97397
Reject -- https://master.php.net/note/reject/97397
Search -- https://master.php.net/manage/user-notes.php