Re: PATCH: anonymous functions in PHP
| From: | Stefan Walk | Date: | Thu, 22 Mar 2007 14:31:56 +0000 |
| Subject: | Re: PATCH: anonymous functions in PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-28549@lists.php.net to get a copy of this message | ||
On 22/03/07, Christian Schneider <cschneid@cschneid.com> wrote:
function sort_by_key($key) { return function($a, $b) { if ($a[$key] < $b[$key])Plain old google brought up: http://groovy.codehaus.org/Martin+Fowler's+closure+examples+in+Groovy among other hits (Groovy syntax should be easy enough to follow). He said real-life examples (-:C - ChrisIf somebody has a real-life demonstrated NEED for the closures/scoping, by all means, bring it up.
return -1;if ($a[$key] == $b[$key])
return 0;return 1; } } $a = array( array('id' => 0, 'first_name' => 'john', 'last_name' => 'connor'), ... ); usort($a, sort_by_key('last_name'));