Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 579 Bytes

map.md

File metadata and controls

33 lines (24 loc) · 579 Bytes

map

Description

Apply a function over all the items of a collection and returns an array with the results keeping the original indexes. You can use the key as the second argument.

Parameters

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

Examples

A multiplier:

<?php

use function Lambdish\Phunctional\map;

return map(
    function ($value) {
        return $value * 2;
    }, 
    [1, 2, 3, 4, 5]
);
            
// => [2, 4, 6, 8, 10]