OK, so after parsing the ini files using parse_ini_file
You should end up with arrays similar to this (when using process sections TRUE):
$first_ini = array(
'MAIN' => array(
'lib' => 'lib_folder',
'bin' => 'bin_folder',
'usr' => 'usr_folder',
'etc' => 'etc_folder'
)
);
$second_ini = array(
'alib' => 1,
'abin' => 0,
'ausr_other' => 'usr/tree'
);
$master_ini = array(
'lib' => 'lib_other',
'abin' => 1
);
Then You can use this simple function (not tested):
function combine_master_with_slave($master, $slave) {
foreach($slave as $key => $val) { // we will loop through slave array
if(is_array($val)) { // if the value is an array use recursion
$slave[$key] = combine_master_with_slave($master, $val);
}
if(isset($master[$key])) { // if master array contains the same key as a slave array, replace it's value by the master's one
$slave[$key] = $master[$key];
}
}
return $slave; // finaly return the processed slave array
}
But I am really not sure whether this will work, maybe it will need some slight modifications...
Also You will have to call this function so many times as many slave arrays You have, or in other words, You will have to call this function for each slave array.
This should work for any sub-array level, even it would be [ [ [ [ [ [][][][] ] ] ] ] ].