NestedArray
in package
Adapted from http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Component/Utility/NestedArray.php @ f86a4d650d5af0b82a3981e09977055fa63f6f2e
Table of Contents
- mergeDeep() : array<string|int, mixed>
- Merges multiple arrays, recursively, and returns the merged array.
- mergeDeepArray() : array<string|int, mixed>
- Merges multiple arrays, recursively, and returns the merged array.
Methods
mergeDeep()
Merges multiple arrays, recursively, and returns the merged array.
public
static mergeDeep() : array<string|int, mixed>
This function is similar to PHP's array_merge_recursive() function, but it handles non-array values differently. When merging values that are not both arrays, the latter value replaces the former rather than merging with it.
Example:
Tags
Return values
array<string|int, mixed> —The merged array.
mergeDeepArray()
Merges multiple arrays, recursively, and returns the merged array.
public
static mergeDeepArray(array<string|int, mixed> $arrays[, bool $preserveIntegerKeys = false ]) : array<string|int, mixed>
This function is equivalent to NestedArray::mergeDeep(), except the input arrays are passed as a single array parameter rather than a variable parameter list.
The following are equivalent:
- NestedArray::mergeDeep($a, $b);
- NestedArray::mergeDeepArray(array($a, $b));
The following are also equivalent:
- call_user_func_array('NestedArray::mergeDeep', $arrays_to_merge);
- NestedArray::mergeDeepArray($arrays_to_merge);
Parameters
- $arrays : array<string|int, mixed>
-
An arrays of arrays to merge.
- $preserveIntegerKeys : bool = false
-
(optional) If given, integer keys will be preserved and merged instead of appended. Defaults to false.
Tags
Return values
array<string|int, mixed> —The merged array.