public function deepMerge (array $mergee, array $merger) {
		$merged = $mergee;

		foreach ($merger as $key => &$value) {

			# If key exists an an array on both sides, deep merge
			if (array_key_exists($key, $merged) && is_array($value) && is_array($merged[$key])) {
				$merged[$key] = $this -> deepMerge($merged[$key], $value);

			# Otherwise, simply replace
			} else {
				$merged[$key] = $value;
			}
		}

		return $merged;
	}
public function deepMerge (array $mergee, array $merger) {
		$merged = $mergee;

		foreach ($merger as $key => &$value) {

			# If key exists an an array on both sides, deep merge
			if (array_key_exists($key, $merged) && is_array($value) && is_array($merged[$key])) {
				$merged[$key] = $this -> deepMerge($merged[$key], $value);

			# Otherwise, simply replace
			} else {
				$merged[$key] = $value;
			}
		}

		return $merged;
	}
public function deepMerge ( array $ mergee , array $ merger ) { $ merged = $ mergee ; foreach ( $ merger as $ key => & $ value ) { # If key exists an an array on both sides, deep merge if ( array_key_exists ( $ key , $ merged ) && is_array ( $ value ) && is_array ( $ merged [ $ key ] ) ) { $ merged [ $ key ] = $ this -> deepMerge ( $ merged [ $ key ] , $ value ) ; # Otherwise, simply replace } else { $ merged [ $ key ] = $ value ; } } return $ merged ; }
Performs an array merge, but when both values for a key are arrays, a deep merge will occur, retaining the unique keys of both without changing the value types.

@example
$a = array(1 => 2, 3 => array(4 => 5, 6 => 7));
$b = array(3 => array(4 => "Four"));
deepMerge($a, $b) == array(1 => 2, 3 => array(4 => "Four", 6 => 7));

@param array &$mergee		The array whose values will be overridden during merging.
@param array &$merger		The array whose values will override during merging.

@return array
Performs an array merge but when both values for a key are arrays a deep merge will occur retaining the unique keys of both without changing the value types .