DEV Community

Brent Roose
Brent Roose

Posted on • Originally published at

Short closures in PHP 7.4

Short closures are a way of writing cleaner short functions in PHP:

// A collection of Post objects
$posts = [/* … */];

$ids = array_map(fn($post) => $post->id, $posts);

You can read all about them here:

Top comments (1)

sergey_telpuk profile image
Sergey Telpuk

As for me It's a great change, but It'd better use construct like ()=> - it's shorter