src/Silex/Provider/YamlConfigServiceProvider.php
protected function mergeConfigurations(array $config1, array $config2)
    {
        $merged = $config1;
        foreach ($config2 as $key => $value) {
            if (is_array($value)
                && isset ($merged [$key]) && is_array($merged [$key])
            ) {
                $merged [$key] = $this->mergeConfigurations($merged [$key], $value);
            } else {
                $merged [$key] = $value;
            }
        }
        return $merged;
    }
protected function mergeConfigurations(array $config1, array $config2)
    {
        $merged = $config1;
        foreach ($config2 as $key => $value) {
            if (is_array($value)
                && isset ($merged [$key]) && is_array($merged [$key])
            ) {
                $merged [$key] = $this->mergeConfigurations($merged [$key], $value);
            } else {
                $merged [$key] = $value;
            }
        }
        return $merged;
    }
Merge configurations arrays recursively. Overwrite values on $config1
with $config2 if already exists.

@param array $config1 Original configuration
@param array $config2 Configuration to be merged

@return array