minwork/array
Minwork Array provides fast, well-tested helpers for nested, associative, and object arrays. Get/set/has plus map, filter, find, group, sort, and validation, with fluent-style chaining. No dependencies; modern PHP syntax.
Arr::pack(array $array): array
Converts map of keys concatenated by dot and corresponding values to multidimensional array.
Inverse of unpack.
Let's use result array from example below.
$array = [
'key1.key2.key3.foo' => 'test',
'key1.key2.key3.bar' => 'test2',
'key1.abc.0' => 'test3',
'xyz' => 'test4',
'0' => 'test5',
];
Arr::pack($array) ->
[
'key1' => [
'key2' => [
'key3' => [
'foo' => 'test',
'bar' => 'test2',
]
]
'abc' => ['test3'],
],
'xyz' => 'test4',
'test5'
]
// Unpack is inverse operation to pack
$array2 = [
'test',
[
'foo' => ['bar'],
'a' => [
'b' => 1
]
]
];
Arr::unpack(Arr::pack($array2)) === $array2 -> true
How can I help you explore Laravel packages today?