On 22/03/07, Christian Schneider <[EMAIL PROTECTED]> wrote:
>> If somebody has a real-life demonstrated NEED for the
>> closures/scoping, by all means, bring it up.
>
> 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

- Chris

function sort_by_key($key) {
 return function($a, $b) {
   if ($a[$key] < $b[$key])
     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'));

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to