Wow I didn't know PHP had closures. I'm now using them all over the place.
Name:
Anonymous2006-04-07 4:07
Create anonymous functions with create_function, like create_function('$a,$b','return ' . ($reverse ? '-' : '') . 'strcasecmp($a,$b)')
As you can see, you can reference outside variables. Not elegant, and not the easiest to write (either as I showed or using double quotes and escaping inside variable $), but does the job.
You can use anonymous functions for functions like array_map, array_filter, array_reduce, array_walk, array_walk_recursive, usort, and other functions (possibly your own) expecting or returning a callback. You can invoke variable functions like $x(lol).