2つの*.iniファイルがある場合:
one.ini
[production]
someArray[] = 'one'
someArray[] = 'two'
someArray[] = 'three'
[development : production]
two.ini
[production]
someArray[] = 'four'
[development : production]
両方の*.iniファイルをZend_Config_Iniインスタンスとしてロードします
$one = new Zend_Config_Ini(
APPLICATION_PATH . "/configs/one.ini",
APPLICATION_ENV,
array('allowModifications' => true)
);
$two = new Zend_Config_Ini(
APPLICATION_PATH . "/configs/two.ini",
APPLICATION_ENV,
array('allowModifications' => true)
);
$one->merge($two);
print_r($one->toArray());
マージ後の出力:
Array
(
[someArray] => Array
(
[0] => four
[1] => two
[2] => three
)
)
出力が以下の例のようになるように配列をマージすることは可能ですか?
各*.iniファイルの配列に数値インデックスを定義することで実行できることはわかっていますが、可能であれば、これは避けたいと思います。
//Ideal merge results
Array
(
[someArray] => Array
(
[0] => one
[1] => two
[2] => three
[3] => four
)
)