Extend one array with another. Non associative arrays will not be merged
but rather replaced.

@return array
321852
public static function extendDistinct()
    {
        $merged = [];

        foreach (func_get_args() as $array) {
            foreach ($array as $key => $value) {
                if (is_array($value) && static::has($merged, $key) && is_array($merged[$key])) {
                    if (static::isAssoc($value) && static::isAssoc($merged[$key])) {
                        $merged[$key] = static::extendDistinct($merged[$key], $value);

                        continue;
                    }
                }

                $merged[$key] = $value;
            }
        }

        return $merged;
    }
79161
public static function convertToOneDimensionalArray($array)
    {
        $newArray = array();
        if (is_array($array))
        {
            foreach ($array as $value)
            {
                $newArray = array_merge($newArray, self::convertToOneDimensionalArray($value));
            }
        } else
        {
            $newArray[] = $array;
        }

        return $newArray;
    }
1118068
protected function merge_arrays() {
        $arrays = func_get_args();
        $narrays = count($arrays);

        // check arguments
        // comment out if more performance is necessary (in this case the foreach loop will trigger a warning if the argument is not an array)
        for ($i = 0; $i < $narrays; $i ++) {
            if (!is_array($arrays[$i])) {
                // also array_merge_recursive returns nothing in this case
                trigger_error('Argument #' . ($i+1) . ' is not an array - trying to merge array with scalar! Returning false!', E_USER_WARNING);
                return false;
            }
        }

        // the first array is in the output set in every case
        $ret = $arrays[0];

        // merege $ret with the remaining arrays
        for ($i = 1; $i < $narrays; $i ++) {
            foreach ($arrays[$i] as $key => $value) {
                if (is_array($value) && isset($ret[$key])) {
                    // if $ret[$key] is not an array you try to merge an scalar value with an array - the result is not defined (incompatible arrays)
                    // in this case the call will trigger an E_USER_WARNING and the $ret[$key] will be false.
                    $ret[$key] = $this->merge_arrays($ret[$key], $value);
                } else {
                    $ret[$key] = $value;
                }
            }
        }

        return $ret;
    }
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;
    }
1373313
public static function merge() 
	{
		// get all arguments
		$arrs = func_get_args();
		$return = array();

		foreach ( $arrs as $arr )
		{
			if ( !is_array( $arr ) ) 
			{
				throw new \InvalidArgumentException('CCArr::merge - all arguments have to be arrays.');
			}

			foreach ( $arr as $key => $value ) 
			{	
				if ( array_key_exists( $key, $return ) ) 
				{
					if ( is_array( $value ) && is_array( $return[$key] ) ) 
					{
						$value = static::merge( $return[$key], $value );
					}
				}
				$return[$key] = $value;
			}
		}

		return $return;
	}
29506
public static function array_merge_recursive()
  {
    if ( func_num_args() < 2 ){
      trigger_error(__METHOD__ .' needs two or more array arguments', E_USER_WARNING);
    }
    
    $arrays = func_get_args();
    $merged = [];
    
    while($arrays){
      $array = array_shift($arrays);
      if ( !is_array($array) ){
        trigger_error(__METHOD__ .' encountered a non array argument', E_USER_WARNING);
      }
      
      if ( !$array ){
        continue;
      }
      
      foreach($array as $key => $value){
        if ( is_string($key) ){
          if ( is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key]) ){
            $merged[$key] = call_user_func([__NAMESPACE__ . '\\Arrayhelper', __METHOD__], $merged[$key], $value);
          }
          else {
            $merged[$key] = $value;
          }
        }
        else {
          $merged[] = $value;
        }
      }
    }
    
    return $merged;
  }
589074
public function mergeSubtables()
    {
        $result = $this->getEmptyClone();
        foreach ($this->getDataTables() as $label => $childTable) {
            $result->addTable($childTable->mergeSubtables(), $label);
        }
        return $result;
    }
266018
public static function add(array ...$arrays): array
    {
        self::checkArrayLengths($arrays);

        $number_of_arrays = count($arrays);
        $length_of_arrays = count($arrays[0]);
        $sums             = array_fill(0, $length_of_arrays, 0);

        for ($i = 0; $i < $length_of_arrays; $i++) {
            for ($j = 0; $j < $number_of_arrays; $j++) {
                $sums[$i] += $arrays[$j][$i];
            }
        }

        return $sums;
    }
121025
public function mergeF ()
	{
		$args = func_get_args();

		foreach ($args as $arg) {
			if (is_an_array($arg)) {
				if ($arg instanceof self) {
					$arg = $arg->to_array();
				}

				foreach ($arg as $key => $value) {
					$this->offsetSet(strtolower($key), $value);
				}
			} else {
				/* XXX: Do we really support this? Object instances are
				 *      supposed to be hashes, Vector instances can be appended
				 *      to. */
				$this->storage []= $arg;
			}
		}

		return $this;
	}
659013
public function mergeAttr()
    {
        $arrays = func_get_args();
        $result = array();

        foreach ($arrays as $array) {
            $result = $this->mergeRecursive($result, $array);
        }

        return $result;
    }
614683
public function toArray()
    {
        $items = array();
        foreach ($this->items as $key => $item) {
            if (is_numeric($item)) {
                $item = DataObject::get_by_id($this->dataClass, $item);
            }
            if (!empty($this->extraFields[$key])) {
                $item->update($this->extraFields[$key]);
            }
            $items[] = $item;
        }
        return $items;
    }
518170
public static function merge(): array
    {
        $arguments = [];
        foreach (func_get_args() as $key => $val) {
            if (!Any::isArray($val)) {
                $val = [];
            }

            $arguments[$key] = $val;
        }
        return call_user_func_array('array_merge', $arguments);
    }
552243
public function extend($extends, $append = false)
    {
        if ($extends instanceof self) {
            $extends = $extends->toArray();
        }

        if ($append) {
            $a = $this->items;
            $b = $extends;
        } else {
            $a = $extends;
            $b = $this->items;
        }

        $this->items = $this->deepMerge($a, $b);

        return $this;
    }
560235
public function extend() 
    {
        // supply type validation
        $type = $this->getAttribute("supplyType");
        $validTypes = [self::TYPE_INCREASE, self::TYPE_DECREASE];
        if (! $type || ! in_array($type, $validTypes)) {
            $type = self::TYPE_INCREASE;
            $this->setAttribute("supplyType", $type);
        }

        // always positive delta
        $delta = abs($this->delta ?: 0);

        return [
            "mosaicId" => $this->mosaicId()->toDTO(),
            "supplyType" => $type,
            "delta" => $delta,
            // transaction type specialization
            "type" => TransactionType::MOSAIC_SUPPLY_CHANGE,
        ];
    }
1163474
public static function merge($array1, $array2)
	{
		$result = [];
		for ($i = 0; $i < func_num_args(); $i++) {
			$result = parent::merge($result, static::asArray(func_get_arg($i)));
		}

		return $result;
	}
954237
public function toObjectArray() : array
    {
        if ($this->isEmpty()) {
            return [];
        }

        $skeleton = $this->_model;

        return array_map(function ($entry) use ($skeleton) {
            return Model::cloneResult($skeleton, $entry);
        }, $this->toArray());
    }
1325665
public function merge()
    {
        $array = $this->getResult();
        foreach ($array as $key => $value) {
            $value['name'] = $value['0'];
            $value['type'] = $value['1'];
            $value['key'] = $value['0'].' :';
            $value['value'] = '';
            unset($value['1']);
            unset($value['0']);
            $this->result[] = $value;
        }

        return $this->result;
    }