예제 #1
0
 protected function addConfig($config)
 {
     $this->config = array_outer_join($this->config, $config);
 }
예제 #2
0
/**
 * adds all elements of the child to the parent while preserving the parents type (array or variable)
 *
 * @param array $parent
 * @param array $child
 * @return array
 * @author Florian Moser
 */
function array_outer_join(array $parent, array $child)
{
    $merged = $parent;
    foreach ($child as $key => $value) {
        if (isset($merged[$key])) {
            if (is_array($merged[$key])) {
                if (is_array($value)) {
                    $merged[$key] = array_outer_join($merged[$key], $value);
                } else {
                    $merged[$key] = array_outer_join($merged[$key], array($value));
                }
            } else {
                $merged[$key] = $value;
            }
        } else {
            $merged[$key] = $value;
        }
    }
    return $merged;
}