Kirki_Helper::recurse PHP Method

recurse() public static method

Helper method to be used from the array_replace_recursive method.
public static recurse ( array $array, array $array1 ) : array
$array array The first array.
$array1 array The second array.
return array
        public static function recurse($array, $array1)
        {
            foreach ($array1 as $key => $value) {
                // Create new key in $array, if it is empty or not an array.
                if (!isset($array[$key]) || isset($array[$key]) && !is_array($array[$key])) {
                    $array[$key] = array();
                }
                // Overwrite the value in the base array.
                if (is_array($value)) {
                    $value = self::recurse($array[$key], $value);
                }
                $array[$key] = $value;
            }
            return $array;
        }