Dot Array: Nested arrays one path away
Stop chaining isset() checks. Read, write, check and delete any value in a nested array with a path like user.profile.name, or every value at once with users.*.email.
Everything you need to work with nested arrays
Wrap an array with dot() and use one small, predictable API.
Dot-Notation Paths
get('user.profile.name'), set('a.b.c', 1). Missing keys are created for you on write.
Wildcards
users.*.email reads, updates, checks or deletes the value in every element, nested wildcards included.
Safe Defaults
get() falls back to your default for missing paths and null values, while has() still sees a key set to null.
Escaping
config.app\.name reads a key with a dot in it, and items.\* a key that is literally *.
Reference Mode
Point it at your own array with setReference() and every change lands there.
ArrayAccess & Countable
$dot['user.name'], isset(), unset(), count(), iteration and json_encode() all work.
A quick look
Plain paths for one value, wildcards for all of them.
1$dot = dot($payload); 2 4$dot->get('users.*.name'); // ["Ahmed", "Sara"] 5$dot->get('users.1.phone', 'n/a'); // "n/a" 6 7$dot->set('users.*.active', true) 8 ->set('meta.synced_at', time()); 9 10$dot->delete('users.*.password');11$dot->has('users.*.profile.email'); // trueDot Array Questions
Quick answers about installing and using Dot Array.
What is Dot Array?
Read, write, check and delete values in deeply nested PHP arrays with dot-notation paths like user.profile.name and wildcards like users.*.email. It's a free, open-source PHP package by Pharaonic.
How do I install Dot Array?
Run composer require pharaonic/php-dot-array in your project's root directory.
What does Dot Array require?
The latest release requires PHP 8.5+.
Does it depend on Laravel or another framework?
No. Dot Array is plain PHP; its only dependency is pharaonic/php-readable, another framework-independent Pharaonic package, so it works in any project. It doesn't use or replace Laravel's Arr or data_get().
What does a wildcard return?
A list with one entry per matched element, so get('users.*.name') gives ["Ahmed", "Sara"]. Nested wildcards give one flat list, and elements where the rest of the path is missing or null get the default.
How do I read a key that contains a dot?
Escape the dot with a backslash: get('config.app\.name') reads the key app.name. Use \* for a key that is literally *.
Is Dot Array free to use?
Yes. Dot Array is open source under the MIT license, so you can use it in personal and commercial projects.
Where can I find the Dot Array documentation?
Read the Dot Array documentation for setup and usage examples.
How do I report a bug or contribute to Dot Array?
Open an issue or a pull request on GitHub, or ask in the Pharaonic Discord.
Ready to dig in?
Read the full documentation for reading and writing values, default values, wildcards, escaping, ArrayAccess, reference mode, JSON, and upgrading from 2.x.