PHP 8 · Types and functions
Write an arrow function
A short closure that captures outer variables automatically.
$doubled = array_map(fn ($n) => $n * 2, $numbers);
PHP 8 · Types and functions
A short closure that captures outer variables automatically.
$doubled = array_map(fn ($n) => $n * 2, $numbers);
Was this page helpful?