数字相加
@param array $arr1
@param array $arr2
@return array
172109
public static function array_add(array $arr1, array $arr2)
    {
        $newArr = $arr1 ? $arr1 : [];
        foreach ($arr2 as $key => $value) {
            $newArr[] = $value;
        }
        return $newArr;
    }
126440
protected function neq($arr, $arr2, $keys): bool
    {
        return !$this->eq($arr, $arr2, $keys);
    }
1203366
final public function insert(array $arr = [])
    {
        if (!$this->pdo) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_UNCONNECT_DATABASE);
        }
        $keys = [];
        if (count($arr) === 0) {
            return false;
        }
        $temp = $arr;
        $ele = array_pop($temp);
        if (is_array($ele)) {
            $keys = array_keys($ele);
        } else {
            $keys = array_keys($arr);
            $arr = [$arr];
        }
        //整理keys
        $params = array_map(function ($item) {
            return ':' . $item;
        }, $keys);
        $keys = array_map(function ($item) {
            return $this->formatColumn($item);
        }, $keys);

        $sql = "insert into " . $this->getTable() . " (" . implode(',', $keys) . ") values (" . implode(',', $params) . ")";
        $this->sql = $sql;
        /**
         * 只获取sql
         */
        if ($this->justSql) {
            return true;
        }
        $sth = $this->pdo->prepare($sql);
        $lastid = null;
        !$this->_begintransaction && count($arr) > 1 && $this->pdo->beginTransaction();
        foreach ($arr as $val) {
            $sth->execute($val);
            $lastid = $this->pdo->lastInsertId();
        }
        !$this->_begintransaction && count($arr) > 1 && $this->pdo->commit();
        $this->lastQueryAt = time();
        $this->resetCon();
        return $lastid;
    }
1249517
public function arrayIntersectFunc($array1, $array2)
    {
        if ($array1 instanceof Collection && $array2 instanceof Collection) {
            return $array1->intersect($array2);
        }

        return array_intersect($array1, $array2);
    }
1317638
public static function arrayGroup($arr, $key){
        $result = [];
        foreach($arr as $k=>$v){
            $result[$v[$key]][] = $v;
        }
        return $result;
    }
996995
public function mergeArrays(array $array1, array $array2)
    {
        $allKeysNumeric = true;

        $config1Keys = array_keys($array1);
        $config2Keys = array_keys($array2);

        foreach ($config1Keys as $configKey) {
            if ( ! is_numeric($configKey)) {
                $allKeysNumeric = false;
                break;
            }
        }

        if ($allKeysNumeric) {
            foreach ($config2Keys as $configKey) {
                if ( ! is_numeric($configKey)) {
                    $allKeysNumeric = false;
                    break;
                }
            }
        }

        if ($allKeysNumeric) {
            return array_merge($array1, $array2);
        }

        $combined = [];

        foreach ($array1 as $key1 => $value1) {
            $value2 = array_key_exists($key1, $array2) !== false ? $array2[ $key1 ] : null;

            if (is_null($value2) || ( ! is_scalar($value1) && ! is_array($value1)) ||
                ( ! is_scalar($value2) && ! is_array($value2))) {
                $combined[ $key1 ] = $value1;

                continue;
            }

            if (is_scalar($value1) || is_null($value1)) {
                if (is_array($value2)) {
                    $combined[ $key1 ] = $this->mergeArrays([$value1], $value2);
                } else {
                    $combined[ $key1 ] = $value2;
                }

                continue;
            }

            if (is_array($value1)) {
                if (is_scalar($value2)) {
                    $combined[ $key1 ] = $value1;
                    $combined[ $key1 ][] = $value2;

                    continue;
                }

                if (is_array($value2)) {
                    $combined[ $key1 ] = $this->mergeArrays($value1, $value2);

                    continue;
                }
            }
        }

        foreach ($array2 as $key2 => $value2) {
            if ( ! is_numeric($key2) && ! array_key_exists($key2, $combined) !== false) {
                if (preg_match('/(.*)\+$/', $key2, $matches)) {
                    $key2 = array_key_exists(1, $matches) ? $matches[ 1 ] : null;

                    if (array_key_exists($key2, $combined) !== false) {
                        $combinedValue = $combined[ $key2 ];

                        if ( ! is_array($combinedValue)) {
                            $combined[ $key2 ] = [$combinedValue];
                        }

                        $combined[ $key2 ][] = $value2;
                    } else {
                        $combined[ $key2 ] = $value2;
                    }
                } else if (preg_match('/(.*)\-$/', $key2, $matches)) {
                    $key2 = array_key_exists(1, $matches) ? $matches[ 1 ] : null;

                    if (array_key_exists($key2, $combined) !== false) {
                        $combinedValue = $combined[ $key2 ];

                        if (is_array($combinedValue)) {
                            foreach ($combinedValue as $combinedValueKey => $combinedValueValue) {
                                if ($combinedValueValue === $value2) {
                                    unset($combinedValue[ $combinedValueKey ]);
                                }
                            }

                            $combined[ $key2 ] = $combinedValue;
                        } else {
                            if ($combinedValue === $value2) {
                                unset($combined[ $key2 ]);
                            }
                        }
                    }
                } else {
                    $combined[ $key2 ] = $value2;
                }
            }
        }

        return $combined;
    }
496902
public static String[] subtraction(String[] arr1, String[] arr2) {
        if (arr1 == null || arr1.length == 0 || arr2 == null || arr2.length == 0) {
            return arr1;
        }
        List<String> list = new ArrayList<String>(Arrays.asList(arr1));
        list.removeAll(Arrays.asList(arr2));
        return list.toArray(new String[0]);
    }
433856
public function array2list($arr, $type = null)
    {
        if (!is_array($arr)) {
            return $this->quote($arr, $type);
        }

        foreach ($arr as $idx => $item) {
            $arr[$idx] = $this->quote($item, $type);
        }

        return implode(',', $arr);
    }
1257917
public static void add(double[] array1, double[] array2) {
        assert (array1.length == array2.length);
        for (int i=0; i<array1.length; i++) {
            array1[i] += array2[i];
        }
    }
1369262
public static function addValue(array &$arr, $key, $value)
    {
        if (isset($arr[$key])) {
            if (!is_array($arr[$key])) {
                $arr[$key] = [$arr[$key]];
            }
            $arr[$key][] = $value;
        }
        else {
            $arr[$key] = $value;
        }
    }
571469
public static <T> List<T> intersection(List<T> arr1, int start1, int end1, List<T> arr2,
                                           int start2, int end2) {
        if (start1 > end1 || start2 > end2) {
            throw new IllegalArgumentException("起始位置必须小于等于结束位置");
        }
        if (start1 == end1 || start2 == end2) {
            return Collections.emptyList();
        }

        List<T> list = new ArrayList<>();
        for (int i = start1; i < end1; i++) {
            int index = arr2.indexOf(arr1.get(i));
            if (index < end2 && index >= start2) {
                list.add(arr1.get(i));
            }
        }
        return list;
    }
605197
private static function sort_multi(& $arr, array $args)
    {
        $sortArray = [];
        $sortRule = '';
        foreach ($args as $sortField => $sortDir) {
            foreach ($arr as $offset => $row) {
                $sortArray[$sortField][$offset] = $row[$sortField];
            }
            $sortRule .= '$sortArray[\'' . $sortField . '\'], ' . $sortDir . ', ';
        }
        if (empty($sortArray) || empty($sortRule)) {
            return $arr;
        }
        eval('array_multisort(' . $sortRule . '$arr);'); //引用传值
        return $arr;
    }
89260
public static function except($array1, $array2)
    {
        $result = [];

        foreach ($array1 as  $key => $value) {
            if (!static::contains($array2, $value)) {
                if (is_int($key)) {
                    static::add($array, $value);
                } else {
                    static::add($array, $value, $key);
                }
            }
        }

        foreach ($array2 as  $key => $value) {
            if (!static::contains($array1, $value) && !self::contains($result, $value)) {
                if (is_int($key)) {
                    static::add($array, $value);
                } else {
                    static::add($array, $value, $key);
                }
            }
        }

        return $result;
    }
1117599
public static function mergeExtraArray($mergeDeep, $array1, $array2)
    {
        if ($mergeDeep) {
            return NestedArray::mergeDeep($array1, $array2);
        }

        return array_merge($array1, $array2);
    }
1251778
public static function before($arr, $i) {
		$res = [];
		foreach($arr as $k=>$v) {
			if($k === $i)
				return $res;
			$res[$k] = $v;
		}
		return $res;
	}
969984
public static String[] intersection(String[] arr1, String[] arr2) {
        if (arr1 == null || arr2 == null) {
            return null;
        }
        if (arr1.length == 0 || arr2.length == 0) {
            return new String[0];
        }
        List<String> list = new ArrayList<String>(Arrays.asList(arr1));
        list.retainAll(Arrays.asList(arr2));
        return list.toArray(new String[0]);
    }
1348642
public function arrMapParse(&$arr){
        $temp = [];
        foreach ($arr as $k => $v){
            $temp[$this->arrMapGetName($k)] = $v;
        }
        return $temp;
    }