The lambda anonymous function is part of PHP 5.3. What use does it have? Is there anything that one can only do with lambda? Is lambda better for certain tasks?
I\'
Anything that requires a temporary function that you probably will only use once.
I would use them for callbacks, for functions such as:
E.g.
usort($myArray, function ($a, $b) {
return $a < $b;
});
Before 5.3, you'd have to..
function mySort ($a, $b) {
return $a < $b;
}
usort($myArray, 'mySort');
Or create_function ...
usort($myArray, create_function('$a, $b', 'return $a < $b;'));