punarinta / apath
A way to access data for multidimensional PHP arrays and objects.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/punarinta/apath
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2025-09-28 02:10:31 UTC
README
A way to access data in objects and multidimensional arrays.
Usage
use APath\APath; $sample = [ 'foo' => [ 'bar' => [ 'x1' => 'hello, world', 'x2', 'x3' => 'bye-bye, world', ], ], 'some' => [ 'data', 'x1337' => 'LEET', ], [1, 4, 'xxx' => 'yyy', 88], ]; // get the whole structure print_r(APath::get($sample)); // get by keys print_r(APath::get($sample, 'foo.bar')); // or by numeric offset print_r(APath::get($sample, '0.2')); // or even combine them print_r(APath::get($sample, 'some.0')); // trying to get a non-existent part will simply result a null print_r(APath::get($sample, 'some.unreal.path'));