Merging and summing multi-dimensional arrays
Presuming that the format will be consistent, you could remove one foreach loop and extract the domain to use as the key of the merged array, and also only either set the sub array (with keys X1, Y1 and Y2) or add to the sub array items. 

foreach($array as $subArray) {
    if (isset($subArray['INFO']) &amp;&amp; isset($subArray['INFO']['DOMAIN'])) {
        $domainKey = $subArray['INFO']['DOMAIN'];
        if (!isset($merged[$domainKey])) {
            $merged[$domainKey] = $subArray;
        }
        else { // could add conditionals to ensure X1 is set on $subArray
            foreach($subArray['X1'] as $key =&gt; $value) {
                $merged[$domainKey]['X1'][$key] += $value;
            }
        }
    }
}


See it in action in this playground example.

A functional approach could also be employed by using array_reduce():

$merged = array_reduce($array, function($cumulative, $subArray) {
    if (isset($subArray['INFO']) &amp;&amp; isset($subArray['INFO']['DOMAIN'])) {
        $domainKey = $subArray['INFO']['DOMAIN'];
        if (!isset($cumulative[$domainKey])) {
            $cumulative[$domainKey] = $subArray;
        }
        else { // could add conditionals to ensure X1 is set on $subArray
            foreach($subArray['X1'] as $key =&gt; $value) {
                $cumulative[$domainKey]['X1'][$key] += $value;
            }
        }
    }
    return $cumulative;
}, []);


See it in action in this playground example