<?php
echo preg_replace_callback('~-([a-z])~', function ($match) {
return strtoupper($match[1]);
}, 'hello-world');
// выведет helloWorld
?>
<?php
$greet = function($name)
{
printf("Hello %s\r\n", $name);
};
$greet('World');
$greet('PHP');
?>
<?php
$arr = array(1, 2, 3, 4, 5);
$func = function($par) use ($n){
return $par + $n;
};
$n = 1;
$b = array_map($func, $arr);
print_r($b);
// Выведит: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )
?>