PHPnews.io

Overview for 'stitcher-io'

Arrow functions in PHP 7.4

Written by Stitcher.io / Original link on May. 1, 2019

Short closures, also called arrow functions, are a way of writing shorter functions in PHP. This notation is useful when passing closures to functions like array_map or array_filter. This is what they look like: // A collection of Post objects $posts = [/* … */]; $ids = array_map(fn($post) => $p…