<?php
use Zend\Config\Config;
use Zend\Debug\Debug;
$array1 = [
'base' => [
'env' => 'prod',
'path' => '//config1',
'credentials' => [
'user' => 'johnDoe42',
'password' => 'hfvggjihdsc63vg',
],
'val1' => 'config1',
],
];
$array2 = [
'base' => [
'env' => 'dev',
'path' => '//config2',
'credentials' => [
'user' => 'janeDoe42',
'password' => 'abc123',
],
'val2' => 'config2',
],
];
$allowChanges = true;
$config1 = new Config($array1, $allowChanges);
$config2 = new Config($array2);
$config1->merge($config2);
Debug::dump($config1->toArray());
array(1) {
["base"] => array(5) {
["env"] => string(3) "dev"
["path"] => string(9) "//config2"
["credentials"] => array(2) {
["user"] => string(9) "janeDoe42"
["password"] => string(6) "abc123"
}
["val1"] => string(7) "config1"
["val2"] => string(7) "config2"
}
}