Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 496 Bytes

File metadata and controls

26 lines (18 loc) · 496 Bytes

group_by

Description

Returns an array with the items grouped by the results of applying $fn to each item.

Parameters

fn
Function to apply to every item in the collection.
coll
Collection of values to apply the function.

Examples

Group by string length:

<?php

use function Lambdish\Phunctional\group_by;

return group_by('strlen', ['one', 'two', 'three']);
            
// => [3 => ['one', 'two'], 5 => ['three']]