<?php
function set_config($key, $value, $config = array()){
  // The base case of the recursion is that no keys are left to recurse through
  // so we return the value
  if($key == ''){
    return $value;
  } else {
    // break the key into an array and set the current one to the first item
    $keys        = explode('/', $key);
    $current_key = array_shift($keys);

    // check if the key already exists in the array and if so just update it's contents
    // by merging existing items with the new one
    if(isset($config[$current_key]))
      $config[$current_key] = array_merge($config[$current_key], set_config(join('/',$keys), $value, $config[$current_key]));
    
    // no keys means we are at the base of the recursion, return just the value
    else
      return array($current_key => set_config(join('/',$keys), $value));
  } 

  return $config;
  // done
}

$config = array();
$config = set_config('db/yum/user','val', $config);
print_r($config);
$config = set_config('db/yum/server','val2', $config);
print_r($config);
$config = set_config('db/yum/a/few/more/levels/for/fun','LOLOLOLOL', $config);
print_r($config);

?>