Merges two or more arrays into one recursively.
@see parent::merge()

For integer-keyed elements, the elements from the latter array
will not be appended to the former array if same value already exists.
174974
public static function mergeNoDouble($a, $b)
    {
        $args = func_get_args();
        $res = array_shift($args);
        while (!empty($args)) {
            $next = array_shift($args);
            foreach ($next as $k => $v) {
                if ($v instanceof UnsetArrayValue) {
                    unset($res[$k]);
                } elseif ($v instanceof ReplaceArrayValue) {
                    $res[$k] = $v->value;
                } elseif (is_int($k)) {
                    if (isset($res[$k])) {
                        //$res[] = $v; // in origin version

                        $exkey = array_search($next[$k], $res);
                        if ($exkey === false) {
                            $res[] = $v;
                        } // else: no duplicate
                    } else {
                        $res[$k] = $v;
                    }
                } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) {
                    $res[$k] = self::mergeNoDouble($res[$k], $v);
                } else {
                    $res[$k] = $v;
                }
            }
        }

        return $res;
    }
803902
public static function deepMergePropertiesArray($arrays)
    {
        $result = array();

        foreach ($arrays as $array) {
            foreach ($array as $key => $value) {
                // Renumber integer keys as array_merge_recursive() does. Note that PHP
                // automatically converts array keys that are integer strings (e.g., '1')
                // to integers.
                if (is_integer($key)) {
                    $result[] = $value;
                } // Recurse when both values are arrays.
                elseif (isset($result [$key]) && is_array($result [$key]) && is_array($value)) {
                    $result[$key] = self::deepMergePropertiesArray(array($result [$key], $value));
                } // Otherwise, use the latter value, overriding any previous value.
                else {
                    $result[$key] = $value;
                }
            }
        }

        return $result;
    }
905919
protected static function arrayMerge($a, $b)
    {
        foreach ($b as $k => $v) {
            if (!is_array($v) || isset($a[$k]) && !is_array($a[$k])) {
                $a[$k] = $v;
            } else {
                $a[$k] = self::arrayMerge(isset($a[$k])? $a[$k]: array(), $v);
            }
        }
        return $a;
    }
165220
public function merge($key, $value = null)
    {
        if (is_array($key)) {
            $this->elements = array_merge($this->elements, $key);
        } elseif (is_string($key)) {
            $items = (array) $this->get($key);
            $value = array_merge($items, $this->getArrayItems($value));
            $this->set($key, $value);
        } elseif ($key instanceof self) {
            $this->elements = array_merge($this->elements, $key->all());
        }
    }
998190
public function merge($array, $merge_back=false){
        $this->fields = $merge_back
            ? array_replace_recursive((array)$array, $this->fields)
            : array_replace_recursive($this->fields, (array)$array);
    }
264883
protected function mergeValues(array $values, $merge = true)
    {
        $this->values = $merge ? array_merge($this->values, $values) : $values;
        return $this;
    }
424189
public function merge()
    {
        $marged = NULL;
        foreach (func_get_args() as $arg) {
            // first is override.
            if ($marged === null) {
                $marged = $arg;

            // when mismatch variable type, then override.
            } elseif (gettype($marged) !== gettype($arg)) {
                $marged = $arg;

            // when not array, then override.
            } elseif (! is_array($arg)) {
                $marged = $arg;

            // when both array, then merge recursive.
            } else {
                foreach ($arg as $_key => $_val) {
                    // when int key, then push.
                    if(is_int($_key)) {
                        $marged[] = $_val;
                    // when not exists key, then override.
                    } elseif(! isset($marged[$_key])) {
                        $marged[$_key] = $_val;
                    // merge.
                    } else {
                        $marged[$_key] = $this->merge($marged[$_key], $_val);
                    }
                }
            }
        }
        return $marged;
    }
222861
public function mergeData(array $data)
	{
		$args = func_get_args();
		while (list(,$v) = each($args)) {
			if (is_array($v)) {
				$this->data = array_merge($this->data, $v);
			}
		}
	}
63680
protected function deep_merge_recursive($arrays)
    {
        $result = array();

        foreach ($arrays as $array)
        {
            foreach ($array as $key => $value)
            {
                if (is_integer($key))
                {
                    $result[] = $value;
                }
                elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value))
                {
                    $result[$key] = $this->deep_merge_recursive(array($result[$key], $value));
                }
                // handle embeded object with object value
                elseif (isset($result[$key]) && is_object($result[$key]) && is_object($value))
                {
                    $result[$key] = (object)$this->deep_merge_recursive(array((array)$result[$key], (array)$value));
                }
                // handle embeded object with array value
                elseif (isset($result[$key]) && is_object($result[$key]) && is_array($value))
                {
                    $result[$key] = (object)$this->deep_merge_recursive(array((array)$result[$key], $value));
                }
                else
                {
                    $result[$key] = $value;
                }
            }
        }

        return $result;
    }
813291
public static function array_merge_assoc_recursive($array1, $array2)
    {
        foreach ($array2 as $key => $value) {

            if (is_int($key) && !in_array($array2[$key], $array1, true)) {
                $array1[] = $array2[$key];
            } elseif (!array_key_exists($key, $array1)) {
                $array1[$key] = $value;
            } elseif (is_array($value) && is_array($array1[$key]) ) {
                $array1[$key] = self::array_merge_assoc_recursive($array1[$key], $value);
            } else {
                if (!in_array($value, $array1, true)) {
                    $array1[$key] = $value;
                }
            }
        }

        return $array1;
    }
92474
public static function merge($array1, $array2, $recursive = false)
    {
        if (!self::isValid($array1) ||
            !self::isValid($array2)) {
            return false;
        }

        if ($recursive) {
            return array_merge_recursive($array1, $array2);
        } else {
            return array_merge($array1, $array2);
        }
    }
853628
function merge(arrays, comp) {
		var mid,
			a1, i1,
			a2, i2,
			result;

		if (arrays.length === 1) {
			return arrays[0];
		} else if (arrays.length === 2) {
			// merge two arrays
			a1 = arrays[0];
			a2 = arrays[1];
			i1 = i2 = 0;
			result = [];
			while(i1 < a1.length && i2 < a2.length) {
				if (comp(a2[i2], a1[i1]) > 0) {
					result.push(a1[i1]);
					i1++;
				} else {
					result.push(a2[i2]);
					i2++;
				}
			}
			while(i1 < a1.length) {
				result.push(a1[i1]);
				i1++;
			}
			while(i2 < a2.length) {
				result.push(a2[i2]);
				i2++;
			}
			return result;
		} else {
			mid = Math.floor(arrays.length / 2);
			return merge([
				merge(arrays.slice(0, mid), comp),
				merge(arrays.slice(mid), comp)
			], comp);
		}

	}
1058629
public static function mergeRecursiveDistinct(array &$array1, array &$array2)
    {
        Deprecated::method(3.3, 'Use array_replace_recursive() or Arr::replaceRecursive() instead.');

        $merged = $array1;

        foreach ($array2 as $key => &$value) {
            // if $key = 'accept_file_types, don't merge.
            if ($key == 'accept_file_types') {
                $merged[$key] = $array2[$key];
                continue;
            }

            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
                $merged[$key] = static::mergeRecursiveDistinct($merged[$key], $value);
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }
754017
public function merge(ArrayObject $other, $recursive = TRUE) {
        foreach($other as $key => $value) {
            if($recursive && $this->offsetExists($key)) {
                $ownvalue = $this->offsetGet($key);
                if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) {
                    $ownvalue->merge($value, TRUE);
                    continue;
                }
            }

            $this->offsetSet($key, $value);
        }

        return $this;
    }
456866
function merge ($v)
  {
    if (is_array ($v)) array_mergeInto ($this->A, $v);
    else if ($v instanceof static)
      array_mergeInto ($this->A, $v->A);
    else throw new InvalidArgumentException;
  }
1330359
function merge (a, b) {
  for (var k in b)
    a[k] = a[k] || b[k]
}
1068109
protected function arrayMergeRecursiveDistinct(array $a, array $b, bool $mergeNumericKeys = false): array
    {
        $merged = $a;

        foreach($b as $key => $value) {
            if (!$mergeNumericKeys && is_numeric($key)) {
                $merged[] = $value;
                continue;
            }
            if (is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key])) {
                $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value);
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }