Returns an array with the items grouped by the results of applying $fn to each item.
- fn
- Function to apply to every item in the collection.
- coll
- Collection of values to apply the function.
Group by string length:
<?php
use function Lambdish\Phunctional\group_by;
return group_by('strlen', ['one', 'two', 'three']);
// => [3 => ['one', 'two'], 5 => ['three']]