Last updated on January 30, 2021
Arrow functions also called “short closures”. We can always access the parent scope, there’s no need for the use keyword. Here is a simple example with an arrow function.
$items = [1,2,3,4,5]; $factor = 10; array_map(fn ($item) => $item * $factor, $items)
Above code we can write as show below without arrow function
$items = [1,2,3,4,5]; array_map(function ($item) use ($factor) { return $item* $factor; }, $items)