Skip to content

Kirby 6.0.0

A::map()

A simple wrapper around array_map with a sane argument order

A::map(array $array, callable(mixed): mixed $map): array

Parameters

Name Type Default
$arrayrequired array<array-key, mixed> no default value
$maprequired callable(mixed): mixed no default value

Return type

array<array-key, mixed>

Parent class

Kirby\Toolkit\A

Examples

// why this weird, inconsistent argument order?
$array = array_map(function ($item) {
  // some mapping
}, $array);

// yes!
$array = A::map($array, function ($item) {
  // some mapping
});