public static function mergeDeepArray(array $arrays, $preserve_integer_keys = false)
    {
        $result = [];

        foreach ($arrays as $array) {
            foreach ($array as $key => $value) {
                if (is_integer($key) && !$preserve_integer_keys) {
                    // Renumber integer keys as array_merge_recursive() does unless
                    // $preserve_integer_keys is set to true. Note that PHP automatically
                    // converts array keys that are integer strings (e.g., '1') to integers.
                    $result[] = $value;
                } elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
                    // Recurse when both values are arrays.
                    $result[$key] = self::mergeDeepArray(array($result[$key], $value), $preserve_integer_keys);
                } else {
                    // Otherwise, use the latter value, overriding any previous value.
                    $result[$key] = $value;
                }
            }
        }

        return $result;
    }
public static function mergeDeepArray(array $arrays, $preserve_integer_keys = false)
    {
        $result = [];

        foreach ($arrays as $array) {
            foreach ($array as $key => $value) {
                if (is_integer($key) && !$preserve_integer_keys) {
                    // Renumber integer keys as array_merge_recursive() does unless
                    // $preserve_integer_keys is set to true. Note that PHP automatically
                    // converts array keys that are integer strings (e.g., '1') to integers.
                    $result[] = $value;
                } elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
                    // Recurse when both values are arrays.
                    $result[$key] = self::mergeDeepArray(array($result[$key], $value), $preserve_integer_keys);
                } else {
                    // Otherwise, use the latter value, overriding any previous value.
                    $result[$key] = $value;
                }
            }
        }

        return $result;
    }
public static function mergeDeepArray ( array $ arrays , $ preserve_integer_keys = false ) { $ result = [ ] ; foreach ( $ arrays as $ array ) { foreach ( $ array as $ key => $ value ) { if ( is_integer ( $ key ) && ! $ preserve_integer_keys ) { // Renumber integer keys as array_merge_recursive() does unless // $preserve_integer_keys is set to true. Note that PHP automatically // converts array keys that are integer strings (e.g., '1') to integers. $ result [ ] = $ value ; } elseif ( isset ( $ result [ $ key ] ) && is_array ( $ result [ $ key ] ) && is_array ( $ value ) ) { // Recurse when both values are arrays. $ result [ $ key ] = self :: mergeDeepArray ( array ( $ result [ $ key ] , $ value ) , $ preserve_integer_keys ) ; } else { // Otherwise, use the latter value, overriding any previous value. $ result [ $ key ] = $ value ; } } } return $ result ; }
Merges multiple arrays, recursively, and returns the merged array.

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);

@param array $arrays
An arrays of arrays to merge.
@param bool $preserve_integer_keys
(optional) If given, integer keys will be preserved and merged instead of
appended. Defaults to false.

@return array
The merged array.

@see NestedArray::mergeDeep()
Merges multiple arrays recursively and returns the merged array .