Skip to content
PHP Packagev8.5.xMIT License14.4K+ downloads

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.

$composer require pharaonic/php-dot-array

Compatibility

Each line is released for the versions in its row, read from that release's composer.json. Pick the line that matches your project; a combination not listed isn't supported. Find the right line of every package for your project.

LineLatest releasePHPStatusDocs
v8.5.xv8.5.2 Oct 8, 20268.5Current Docs: Read the v8.5.x docs
v8.4.xv8.4.2 Oct 8, 20268.4Maintained Docs: Read the v8.4.x docs
v8.3.xv8.3.1 Oct 8, 20268.3Maintained Docs: Read the v8.3.x docs
v8.2.xv8.2.1 Oct 8, 20268.2Maintained Docs: Read the v8.2.x docs
v8.1.xv8.1.1 Oct 8, 20268.1MaintainedPHP 8.1 no longer gets security fixes Docs: Read the v8.1.x docs
v8.0.xv8.0.1 Oct 8, 20268.0MaintainedPHP 8.0 no longer gets security fixes Docs: Read the v8.0.x docs

Maintenance

Latest release
v8.5.2
Oct 8, 2026 (1 month ago)
Released lines
6
documented lines with a release; see compatibility
CI on main
Tests passed
latest run Apr 9, 2026

From the package's releases and its GitHub Actions. A passing run means the test suite passed on main, on every PHP version it supports; it isn't a security review, and each release line has its own runs on GitHub. Checked hourly.

A quick look

Plain paths for one value, wildcards for all of them.

app/Support/UserPayload.php
1$dot = dot($payload);
2 
3$dot->get('users.0.profile.email'); // "ahmed@example.com"
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'); // true
Key Features

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.

FAQ

Dot 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.