ridzhi/smarrt

Smart array access

This package's canonical repository appears to be gone and the package has been frozen as a result.

2.0.0 2016-08-08 13:57 UTC

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'])