Michael Walter wrote:
> A simple real-life example is:
> function pick($member)
> {
>  return create_function('$x', 'return $x->'.$member.';');
> }
> 
> which could be used e.g. in
>  array_map(pick('age'), $people).
> Arguably, in this case you could as well write:
>  array_map(function($p) {return $p->age;}, $people);
> but I believe it is easy to see how the problem generalizes.

Funnily enough you already show how this can currently be done.

My point would be to make simple things simple and keep complicated
things possible. As it is right now.

So I'd use
        array_map(function($p) {return $p->age;}, $people);
or
        usort($a, function($a, $b) { return strcmp($a->lastname, $b->lastname); 
});
to do Stefan Walk's example.

But something like your pick function using create_function if I
*really* wanted something more fancy.

- Chris

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

Reply via email to