/** * recursively merges two arrays, overwriting matching keys * * if any of the array elements are an array, they will be merged with an array * with the same key in the base array * * @param array $array the base array * @param array $override the array to merge * @return array */ public static function array_merge2($array, $override) { $x = array(); foreach ($array as $k => $v) { if (isset($override[$k])) { if (is_array($v)) { $v = Participants_Db::array_merge2($v, (array) $override[$k]); } else { $v = $override[$k]; } unset($override[$k]); } $x[$k] = $v; } // add in the remaining unmatched elements return $x += $override; }