public arrayMergeRecursive ( $arr2, $arr1 ) : array | ||
Результат | array |
/** * @param array * @param array * @return array * @static */ function arrayMergeRecursive($arr2, $arr1) { $ret = array(); foreach ($arr2 as $key => $data) { if (!isset($arr1[$key])) { $ret[$key] = $data; unset($arr1[$key]); continue; } if (is_array($data)) { if (!is_array($arr1[$key])) { $ret[$key] = $arr1[$key]; unset($arr1[$key]); continue; } $ret[$key] = PEAR_Config::arrayMergeRecursive($arr1[$key], $arr2[$key]); unset($arr1[$key]); } } return array_merge($ret, $arr1); }