Apply the given $callback function to the every element of the current array, collecting the results.

/**
 * Apply the given $callback function to the every element of the current array,
 * collecting the results.
 *
 * @param callable $callback The callback function.
 */
public function map(callable $callback): self

Examples

$arrays = Arrays::create([1, 2, 3, 4, 5])
                ->map(function ($n) {
                    return ($n * $n * $n);
                })->toArray();

print_r($arrays);

The above example will output:

Array
(
    [0] => 1
    [1] => 8
    [2] => 27
    [3] => 64
    [4] => 125
)

Getting Started

Methods