final class NestedArray (View source)

Reads and changes values in nested arrays given by a path.

The path is a string of keys separated by slashes, eg. Servers/1/host refers to $array[Servers][1][host]

Methods

static mixed
get(string $path, array $array, mixed $default = null)

Returns value of an element in $array given by $path.

static array
set(string $path, array $array, mixed $value)

Stores value in an array

static array
remove(string $path, array $array)

Removes value from an array

Details

static mixed get(string $path, array $array, mixed $default = null)

Returns value of an element in $array given by $path.

Parameters

string $path

path in the array

array $array

the array

mixed $default

default value

Return Value

mixed

array element or $default

static array set(string $path, array $array, mixed $value)

Stores value in an array

Parameters

string $path

path in the array

array $array

the array

mixed $value

value to store

Return Value

array

the array with the value stored

static array remove(string $path, array $array)

Removes value from an array

Parameters

string $path

path in the array

array $array

the array

Return Value

array

the array with the value removed