DEV Community

Brent Roose
Brent Roose

Posted on • Originally published at stitcher.io

1 2

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: https://stitcher.io/blog/short-closures-in-php

Top comments (1)

Collapse
 
sergey_telpuk profile image
Sergey Telpuk

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

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay