composer require weew/helpers-array
This tiny library provides various helper functions to deal with arrays.
Get an item from an array using "dot" notation.
mixed array_get(array $array, mixed $key [, mixed $default = null])
Check if an item exists in an array using "dot" notation.
bool array_has(array $array, mixed $key)
Set an array item to a given value using "dot" notation.
array array_set(array &$array, mixed $key, mixed $value)
Remove one or many array items from a given array using "dot" notation.
void array_remove(array &$array, mixed $keys)
Add an element to the array at a specific location using the "dot" notation.
array array_add(array &$array, mixed $key, mixed $value)
Get an element and remove it from the array using the "dot" notation.
array array_take(array &$array, mixed $key, [, mixed $default = null])
Get the first element from an array.
array array_first(array &$array, [, mixed $default = null])
Get the last element from an array.
array array_last(array &$array, [, mixed $default = null])
Reset all numerical indexes of an array (start from zero). Non-numerical indexes will stay untouched.
array array_reset(array $array [, bool $deep = false])
Flatten a multi-dimensional associative array with dots.
array array_dot(array $array [, string $prepend = ''])
Extend one array with another.
array array_extend(array $arrays [, array $...])
Extend one array with another. Non associative arrays will not be merged but rather replaced.
array array_extend_distinct(array $arrays [, array $...])
Check if the given array is associative.
bool array_is_associative(array $array)
Check if an array has a numeric index.
bool array_is_indexed(array $array)
Check if array contains a specific element.
array array_contains(array $array, mixed $search [, bool $strict = true])