ArrayUtil::get_nested_value( array $array, string $key, mixed $default = null )

Get a value from an nested array by specifying the entire key hierarchy with ‘::’ as separator.


Description Description

E.g. for [ ‘foo’ => [ ‘bar’ => [ ‘fizz’ => ‘buzz’ ] ] ] the value for key ‘foo::bar::fizz’ would be ‘buzz’.


Parameters Parameters

$array

(Required) The array to get the value from.

$key

(Required) The complete key hierarchy, using '::' as separator.

$default

(Optional) The value to return if the key doesn't exist in the array.

Default value: null


Top ↑

Return Return

(mixed) The retrieved value, or the supplied default value.


Top ↑

Source Source

File: src/Utilities/ArrayUtil.php


			

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.