Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Array Laravel Package

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.

View on GitHub
Deep Wiki
Context7

unpack

Definition

Arr::unpack(array $array, int $mode = Arr::UNPACK_ALL): array

Description

Converts multidimensional array to map of keys concatenated by dot and corresponding values.

Inverse of pack.

Modes

Mode Description
Arr::UNPACK_ALL Every array will be unpacked
Arr::UNPACK_PRESERVE_LIST_ARRAY Preserve arrays with highest nesting level (if they are not associative) as element values instead of unpacking them
Arr::UNPACK_PRESERVE_ASSOC_ARRAY Preserve arrays with highest nesting level (if they are associative) as element values instead of unpacking them
Arr::UNPACK_PRESERVE_ARRAY Preserve all arrays with highest nesting level as element values instead of unpacking them

Examples

$array = [
    'key1' => [
        'key2' => [
            'key3' => [
                'foo' => 'test',
                'bar' => 'test2',
            ]
        ]
        'abc' => ['test3'],
    ],
    'xyz' => 'test4',
    'test5'
];

// Equal to Arr::unpack($array, Arr::UNPACK_ALL)
Arr::unpack($array) ->
[
    'key1.key2.key3.foo' => 'test',
    'key1.key2.key3.bar' => 'test2',
    'key1.abc.0' => 'test3',
    'xyz' => 'test4',
    '0' => 'test5',
]

Arr::unpack($array, Arr::UNPACK_PRESERVE_LIST_ARRAY) ->
[
    'key1.key2.key3.foo' => 'test',
    'key1.key2.key3.bar' => 'test2',
    // Preserve list array as value
    'key1.abc' => ['test3'],
    'xyz' => 'test4',
    '0' => 'test5',
]

Arr::unpack($array, Arr::UNPACK_PRESERVE_ASSOC_ARRAY) ->
[
    // Preserve assoc array as value
    'key1.key2.key3' => [
        'foo' => 'test',
        'bar' => 'test2',
    ],
    'key1.abc.0' => 'test3',
    'xyz' => 'test4',
    '0' => 'test5',
]

Arr::unpack($array, Arr::UNPACK_PRESERVE_ARRAY) ->
[
    // Preserve assoc array as value
    'key1.key2.key3' => [
        'foo' => 'test',
        'bar' => 'test2',
    ],
    // Preserve list array as value
    'key1.abc' => ['test3'],
    'xyz' => 'test4',
    '0' => 'test5',
]
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings