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-10-29 04:20:16 UTC


README

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