Anonymous functions in PHP

Author: sandshark

I recently discovered that since PHP 5.3.0 there are anonymous functions, also called lambda functions available.
This is a very nice feature especially for registering a simple callback.

An example:

 <?php
$func = function($value) {
 return $value * 2;
};

print_r(array_map($func, range(1, 5)));
?> 

More information in the PHP Documentation can be found here.

Also, im am trying to post more frequently, and soon reports of my trip to the states will come up here too.

Tags: ,

Leave a Reply