dev-master
9999999-dev
MIT
The Requires
- php ^7.1
The Development Requires
array utility path
v1.0.0
1.0.0.0
MIT
The Requires
- php ^7.1
The Development Requires
array utility path
Wallogit.com
2017 © Pedro Peláez
Yet another array path implementation, (*2)
get()echo (new \PeeHaa\ArrayPath\ArrayPath())->get(['foo' => ['bar' => 'baz']], 'foo.bar'); // baz echo (new \PeeHaa\ArrayPath\ArrayPath())->get(['foo' => ['bar' => 'baz']], 'foo.qux'); // throws \PeeHaa\ArrayPath\NotFoundException
exists()echo (new \PeeHaa\ArrayPath\ArrayPath())->exists(['foo' => ['bar' => 'baz']], 'foo.bar'); // true echo (new \PeeHaa\ArrayPath\ArrayPath())->exists(['foo' => ['bar' => 'baz']], 'foo.qux'); // false
set()$array = []; (new \PeeHaa\ArrayPath\ArrayPath())->set($array, 'foo.bar', 'value'); var_dump($array);
/**
array(1) {
["foo"]=>
array(1) {
["bar"]=>
string(5) "value"
}
}
*/
remove() $array = ['foo' => ['bar' => 'value']];
(new \PeeHaa\ArrayPath\ArrayPath())->remove($array, 'foo.bar');
var_dump($array);
/**
array(1) {
["foo"]=>
array(0) {
}
}
*/
Note: remove() will not throw when the key does not exist in the array., (*3)
MIT
array utility path
MIT
array utility path