ridzhi / smarrt
Smart array access
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 4 541
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 5.1.*
This package is not auto-updated.
Last update: 2023-06-10 12:28:33 UTC
README
Dot-Notation access api
Dot implements ArrayAccess interface.
$arr = [ ... ]; $dot = new Dot($arr);
set
// assoc arrays $dot['node1.node2'] = 'value'; // also you can use dot with indexed array $dot['node1.node2.0.1'] = 'value'; //equal $dot['node1']['node2'][0][1] = 'value' // if key is not exists, it will be created $dot['node1.not_exists_key'] = 'value';
get
// equal $email = $dot['feedbacks'][0]['email'] // if key is not exists, return null $email = $dot['feedbacks.0.email'];
unset/isset/empty
unset($dot['node1.node2']) isset($dot['node1.node2']) empty($dot['node1.node2'])