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);

Official PHP 8 documentation

More types and functions commands

All types and functions commands · PHP 8 cheatsheet

Was this page helpful?