webiik/arr

The Arr provides dot notation for PHP arrays.

1.0 2019-02-28 21:18 UTC

This package is auto-updated.

Last update: 2024-04-29 03:07:23 UTC


README

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e2e737667

Arr

The Arr provides dot notation for PHP arrays.

Installation

composer require webiik/arr

Example

$array = [];
$arr = new \Webiik\Arr\Arr();
$arr->set('dot.notation.key', ['key' => 'val'], $array);

Adding

set

set(string $key, $val, array &$array): void

set() sets value $val to $array under (dot notation) $key.

$arr->set('dot.notation.key', ['key' => 'val'], $array);

add

add(string $key, $val, array &$array): void

add() ads value $val to $array under (dot notation) $key.

$arr->add('dot.notation.key', 'val', $array);

Check

isIn

isIn(string $key, array $array): bool

isIn() determines if $key is set in array and if its value is not NULL.

$arr->isIn('dot.notation.key', $array)

Getting

get

get(string $key, array $array)

get() gets value from $array by (dot notation) $key.

$arr->get('dot.notation.key', $array)

Deletion

delete

delete(string $key, array &$array): void

delete() removes value from $array by (dot notation) $key.

$arr->delete('dot.notation.test', $array);

Resources