Gets a property's value from a (multi-dimensional) array.
Syntax
array_get(array $arr, array|string $path): mixed
Parameter
@param array|null $arr The array to query.
@param array|string|null $path The path of property to query. As an array, e.g.: [ 'a', 'b' ]. As a string, e.g.: 'a.b'.
Return
Returns the property's value.
Returns NULL if $path was not found.
ATTENTION: You can not distinguish if NULL is returned, whether the $path was not found or the value itself is NULL !
Examples
Writing in your twig source code:
Path, as array:
{% set prop = hublify.array_get(myArr, ['a','sub','path']) %}
Path, as dot-notated string:
{% set prop = hublify.array_get(myArr, 'a.sub.path') %}