public function merge_config($config, $localconfig) {

        if (!is_array($config) && !is_array($localconfig)) {
            return $localconfig;
        }

        // Local overrides also deeper default values.
        if (is_array($config) && !is_array($localconfig)) {
            return $localconfig;
        }

        foreach ($localconfig as $key => $value) {

            // If defaults are not as deep as local values let locals override.
            if (!is_array($config)) {
                unset($config);
            }

            // Add the param if it doesn't exists or merge branches.
            if (empty($config[$key])) {
                $config[$key] = $value;
            } else {
                $config[$key] = $this->merge_config($config[$key], $localconfig[$key]);
            }
        }

        return $config;
    }
public function merge_config($config, $localconfig) {

        if (!is_array($config) && !is_array($localconfig)) {
            return $localconfig;
        }

        // Local overrides also deeper default values.
        if (is_array($config) && !is_array($localconfig)) {
            return $localconfig;
        }

        foreach ($localconfig as $key => $value) {

            // If defaults are not as deep as local values let locals override.
            if (!is_array($config)) {
                unset($config);
            }

            // Add the param if it doesn't exists or merge branches.
            if (empty($config[$key])) {
                $config[$key] = $value;
            } else {
                $config[$key] = $this->merge_config($config[$key], $localconfig[$key]);
            }
        }

        return $config;
    }
public function merge_config ( $ config , $ localconfig ) { if ( ! is_array ( $ config ) && ! is_array ( $ localconfig ) ) { return $ localconfig ; } // Local overrides also deeper default values. if ( is_array ( $ config ) && ! is_array ( $ localconfig ) ) { return $ localconfig ; } foreach ( $ localconfig as $ key => $ value ) { // If defaults are not as deep as local values let locals override. if ( ! is_array ( $ config ) ) { unset ( $ config ) ; } // Add the param if it doesn't exists or merge branches. if ( empty ( $ config [ $ key ] ) ) { $ config [ $ key ] = $ value ; } else { $ config [ $ key ] = $ this -> merge_config ( $ config [ $ key ] , $ localconfig [ $ key ] ) ; } } return $ config ; }
Overrides default config with local config values

array_merge does not merge completely the array's values

@param mixed $config The node of the default config
@param mixed $localconfig The node of the local config
@return mixed The merge result
Overrides default config with local config values