Skip to content

Kirby 5.0.1

A::nestByKeys()

Recursively creates a nested array from a set of keys with a key on each level

A::nestByKeys(mixed $value, array $keys): array|mixed

Parameters

Name Type Default Description
$valuerequired mixed no default value Arbitrary value that will end up at the bottom of the tree
$keysrequired array no default value List of keys to use sorted from the topmost level

Return types

arrayormixed

Nested array or (if `$keys` is empty) the input `$value`

Parent class

Kirby\Toolkit\A