Merging two multidimensional associative arrays
There is an alternative to your implementation. If you can change the position of the name element to the array key:

$defaults = array(
    'foo' =&gt; array(
        "level" =&gt; 5,
        "meta" =&gt; array(
            "value" =&gt; 1
        )
    ),
    'bar' =&gt; array(
        "level" =&gt; 6
    )
);

$custom = array(
    'qux' =&gt; array(
        "date" =&gt; "2016-01-01"
    ),
    'tux' =&gt; array(
        "date" =&gt; "2016-01-31"
    ),
    'foo' =&gt; array(
        "date" =&gt; "2015-01-01",
        "meta" =&gt; array(
            "value" =&gt; 5,
            "something" =&gt; "hello world"
        )
    )
);


You can utilize the native PHP function: array_replace_recursive

Using this function will provide you with the same resulting structure as you have shown with the exception of having the names as array keys. If this is an issue to you, you can duplicate the name once more into an array element. 

The reason this specific/unique key is required is to only merge elements related to each other.

This little snippet should translate your array into the required structure:

/**
 * Translates an array element into an unique key for the element.
 *
 * (The name is just an example)
 */
function uniqify(array $array, string $key): array
{
    foreach($array as $index =&gt; $value)
    {
        $array[$value[$key]] = $value;
        unset($array[$index]);
    }
    return $array;
}


You could then so something like this:

$merged = array_replace_recursive(
    uniqify($defaults, 'name'),
    uniqify($custom,   'name')
);


Hope this can help, happy coding!