You could use array_merge():

<?php

require_once 'Zend.php';
Zend::loadClass('Zend_Config');

$master_config = new Zend_Config(array('x' => 1, 'y' => 2, 'z' => 3));
$user_config     = new Zend_Config(array('y' => 4, 'a' => 5));

$config = new Zend_Config(array_merge($master_config->asArray(), $user_config->asArray()));
var_dump($config->asArray());

/* output:
array(4) {
  ["x"]=>
  int(1)
  ["y"]=>
  int(4)
  ["z"]=>
  int(3)
  ["a"]=>
  int(5)
}
*/

?>

nico


[22.12.2006 13:03] Steve wrote:
Hi,

I've been trying to figure out the best way to merge two Zend_Config objects together.

What I want to be able to do is have one master INI file in my application directory and then one INI file per application instance, which will allow me to override settings in the master INI file. I took a look around the documentation and the code for Zend_Config but wasn't able to find an existing way to do this.

What I think I'll have to do is write a recursive iterator or a combination of asArray() and a custom array_merge function but I wanted to check here if I'm missing something and if there is an easier way to accomplish this?

Thanks,

Steve


Reply via email to