This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Astra_Get_Footer_Builder::array_merge_recursive_distinct( array $array1, array $array2 )
Recursively merge two arrays, with values from the second array overwriting the first.
Description
Unlike array_merge_recursive, this doesn’t create nested arrays for duplicate keys.
Parameters
- $array1
-
(array) (Required) The base array.
- $array2
-
(array) (Required) The array to merge in (takes precedence).
Return
(array) The merged array.
Source
File: inc/abilities/customizer/footer/class-astra-get-footer-builder.php
private function array_merge_recursive_distinct( $array1, $array2 ) {
$merged = $array1;
foreach ( $array2 as $key => $value ) {
if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
// If both values are arrays, merge them recursively.
$merged[ $key ] = $this->array_merge_recursive_distinct( $merged[ $key ], $value );
} else {
// Otherwise, use the value from array2.
$merged[ $key ] = $value;
}
}
return $merged;
}
Expand full source code Collapse full source code View on Trac