Combines operators and numbers

@param array $array The subexpression of the formula

@return array
482006
private function combine($array) {
        $new_array = [];
        $i = $j = $key = 0;

        foreach ($array as $item) {

            $array_ip1 = (isset($array[$i+1])) ? $array[$i+1] : null;

            end($new_array);
            $cur = current($new_array);

            if ((strstr('+-', $item)) && (strstr('+-', $cur)) && (strstr('+-', $array_ip1))) {
                if ($item === '-')
                    $new_array[key($new_array)] = ($cur == '+') ? '-' : '+';
            } elseif ((strstr('+-', $item)) && (strstr('*/^', $cur)) && (strstr('+-', $array_ip1))) {
                $new_array[] = $item;
            } else {
                if ((strstr('+-', $item)) && ($key+1 != $i) && (strstr('*/^', $array[$key]))
                && (!is_numeric($array[$key+1])) && (isset($array[$key+1]))) {
                    if ($item === '-')
                        $new_array[key($new_array)] = ($cur == '+') ? '-' : '+';
                } else {
                    $new_array[] = $item;
                    $key = $i;
                }
            }
            $i++;
        }

        $array = $new_array;
        $new_array = [];

        foreach ($array as $item) {

            $array_i = $array[$j];
            $array_ip1 = (isset($array[$j+1])) ? $array[$j+1] : null;
            $array_im1 = (isset($array[$j-1])) ? $array[$j-1] : null;
            $array_im2 = (isset($array[$j-2])) ? $array[$j-2] : null;
            $array_im3 = (isset($array[$j-3])) ? $array[$j-3] : null;

            if ($item === '+' || $item === '-') {
                if (($j == 0 && is_numeric($array_ip1))
                || ($j > 0 && is_numeric($array_ip1)
                && stristr('+-*/^e', $array_im1))) {
                    if ($item === '+') {
                        $new_array[] = $array_ip1;
                    } else {
                        if ($array_im1 === '-' && $array_im2 !== '-') {
                            $new_array[] = $array_ip1;
                        } elseif ($array_im1 === '-' && $array_im3 === '-') {
                            $this->correct = 0;
                            break;
                        } else {
                            $new_array[] = $item.$array_ip1;
                        }
                    }
                } else {
                    if ($item === '-' && $array_ip1 === '-') {
                        if (count($new_array))
                            $new_array[] = '+';
                    } elseif ($item === '-' && $array_ip1 === '+') {
                        if (count($new_array))
                            $new_array[] = '+';
                        $new_array[] = '0';
                        $new_array[] = '-';
                    } else {
                        if (count($new_array) || $item != '+')
                            $new_array[] = $item;
                    }
                }
            } elseif (($j == 1 && is_numeric($item) && strstr('+-', $array_im1))
            || ($j > 1 && is_numeric($item) && strstr('+-', $array_im1)
            && (stristr('+-*/^e', $array_im2)))) {
            } else {
                $new_array[] = $item;
            }
            $j++;
        }
        return $new_array;
    }
241055
protected function filterResults(array $array)
    {
        $curWord = $this->context->getCurrentWord();

        return array_filter($array, function($val) use ($curWord) {
            return fnmatch($curWord.'*', $val);
        });
    }
392515
protected function filterArray(array $array): array
	{
		$newArray = [];

		foreach($array as $row)
		{
			$newArray[] =  (is_array($row)) ? $row[0] : $row;
		}

		return $newArray;
	}
157566
public static function flatten(array $array)
    {
        $out = [];

        foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $item) {
            if (is_int($key)) {
                $out[] = $item;
            } else {
                $out[$key] = $item;
            }
        }

        return $out;
    }
260471
public function flatter($array)
    {
        $result = [];
        foreach ($array as $item) {
            if (is_array($item)) {
                $result = array_merge($result, $this->flatter($item));
            } else {
                $result[] = $item;
            }
        }

        return $result;
    }
429459
public static function merge(array $array)
    {
        $result = array();
        foreach ($array as $config) {
            if (is_string($config)) {
                if (!file_exists($config)) {
                    continue;
                }
                $config = require($config);
            }
            if (!is_array($config)) {
                continue;
            }
            $result = self::mergeArray($result, $config);
        }
        return $result;
    }
569575
protected function sequentialArrayToKey(array $array)
    {

        if ($this->isObjectAndId($array)) {
            return get_class($array[0]) . '-' . $array[1];
        }

        $parts = [];

        foreach ($array as $value) {
            $parts[] = $this->castArrayValue($this->key($value));
        }

        return implode('_', $parts);
    }
621979
public static function expand(array $array)
    {
        $result = array();

        foreach ($array as $key => $value) {
            $references = self::explodeKeys((string)$key); // cast for performance
            $value = self::expandValue($value);

            if (count($references) === 1) {
                $key = $references[0];

                // If the result key is already set, we have to merge
                // the two values.
                if (array_key_exists($key, $result)) {
                    $result[$key] = self::mergeTwoValues($result[$key], $value, array($key));
                }
                else {
                    $result[$key] = $value;
                }
            }
            else {
                self::dereferenceDots($result, $references, $value);
            }
        }

        return $result;
    }
1239053
protected function arrayToKey(array $array)
    {
        if ($this->isSequential($array)) {
            return $this->sequentialArrayToKey($array);
        }

        $parts = [];

        $keys = array_keys($array);
        sort($keys);

        foreach ($keys as $key) {
            $parts[] = $key;
            $parts[] = $this->castArrayValue($array[$key]);
        }

        return implode('_', $parts);
    }
1354262
public static function collapse($array)
    {
        $results = [];
        foreach ($array as $key => $values) {
            if (is_array($values) === false) {
                $results[$key] = $values;

                continue;
            }
            $results = array_merge($results, $values);
        }

        return $results;
    }
162994
public static function flat(array $array)
    {
        $out = [];
        foreach ($array as $key=>$value) {
            if (is_array($value)) {
                //use recursion to get to the next array
                $out = array_merge($out, self::flat($value));
            } else {
                //add the value to the back of the array
                //if the value is not an array
                $out[] = $value;
            }
        }
        //return the resulting array
        return $out;
    }
138361
public function flatten(array $array)
    {
        $tmp = array();
        foreach ($array as $a) {
            if (is_array($a)) {
                $tmp = array_merge($tmp, array_flat($a));
            } else {
                $tmp[] = $a;
            }
        }

        return $tmp;
    }
251987
static public function normaliseValues($array) {
		$array=self::arrayize($array);
		if (!$array) return $array;
		$minValue=min($array);
		$maxValue=max($array);
		if ($maxValue==$minValue) {
			$minValue-=1;
		}
		foreach($array as $index=>$value) {
			$array[$index]=($value-$minValue)/($maxValue-$minValue);
		}
		return $array;
	}
1093868
static public function stringify(array $array)
    {
        $result = array();
        foreach ($array as $key => $value) {
            $result[] = sprintf('%s=%s', $key, $value);
        }
        return implode('&', $result);
    }
364575
protected static function encodeArray($array)
    {
        if (Arrays::isAssoc($array)) {
            $output = [];
            foreach ($array as $key => $val) {
                $output[] = $key . ':' . \addcslashes($val, ': ');
            }

            return self::encodeString(\implode(' ', $output));
        }

        $output = [];
        foreach ($array as $val) {
            $output[] = \addcslashes($val, ': ');
        }

        return self::encodeString(\implode(' ', $output));
    }
1055647
private function trimArray(&$array)
    {
        foreach ($array as $key => $value) {
            if (is_string($value)) {
                $array[$key] = trim($value);
            } else if (is_array($value)) {
                $array[$key] = $this->trimArray($value);
            }
        }

        return $array;
    }
271241
public static function transpose(array $array): array
    {
        $new   = [];
        $keys  = array_keys($array);

        foreach ($keys as $k => $val) {
            foreach ((array) $array[$val] as $k2 => $v2) {
                $new[$k2][$val] = $v2;
            }
        }

        return $new;
    }