Cleanup array from null values.

@param array $haystack
@return array
197758
private function removeEmptyValues(array $haystack)
    {
        foreach ($haystack as $key => $value) {
            if (is_array($value)) {
                $haystack[$key] = $this->removeEmptyValues($value);
            }
            // remove empty values value value is NULL or an empty string ''
            if ($value === null || $value == '') {
                unset($haystack[$key]);
            }
        }
        
        return $haystack;
    }
602210
function clean(values) {
  var index = -1;
  var length = values.length;
  var result = [];
  var prev = null;
  var value;

  while (++index < length) {
    value = values[index];

    if (prev && 'value' in value && value.type === prev.type) {
      prev.value += value.value;
    } else {
      result.push(value);
      prev = value;
    }
  }

  return result;
}
758926
private function arraySearch( $needle, array $haystack ) {
		foreach ( $haystack as $valueOffset => $thing ) {
			if ( $this->valueComparer->valuesAreEqual( $needle, $thing ) ) {
				return $valueOffset;
			}
		}

		return false;
	}
569278
public static function array_ikey_exists($needle, $haystack) {
		if (! \is_array($haystack) || ! \count($haystack)) {
			return false;
		}
		$haystack = \array_keys($haystack);

		return (false !== static::array_isearch($needle, $haystack));
	}
1325767
public function ends_with( $haystack, $needle ) {
		if ( '' === $haystack || '' === $needle ) {
			return false;
		}
		if ( $haystack === $needle ) {
			return true;
		}

		return substr_compare( $haystack, $needle, - strlen( $needle ) ) === 0;
	}
784105
protected function sortHaystack()
    {
        $sorted_haystack = [];
        foreach ($this->haystack as $string) {
            $sorted_haystack[$string] = $this->levenshteinUtf8($this->needle, $string);
        }

        // Apply threshold when set.
        if(!is_null($this->threshold)){
            $sorted_haystack = array_filter($sorted_haystack, function ($score){
                return $score <= $this->threshold;
            });
        }

        asort($sorted_haystack);

        $this->sorted_haystack = $sorted_haystack;
    }
599439
public static function group_in_array($needels, $haystack)
    {
        foreach ($needels as $k) {
            if (!in_array($k, $haystack)) {
                return false;
            }
        }
        return true;
    }
1332507
public static function collectionContains($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if ($value === $needle) {
                return true;
            }
        }

        return false;
    }
1189624
public static function removeNull(array $array)
    {
        $result = [];
        foreach ($array as $key => $value) {
            if (is_null($value)) {
                continue;
            }
            $result[$key] = $value;
        }
        return $result;
    }
853922
public static function contains($haystack, $needle)
    {
        // Check arguments
        if (empty($haystack) || empty($needle)) {
            return false;
        }

        // Needle is string
        if (!is_array($needle)) {
            return mb_strpos($haystack, $needle) !== false;
        }

        // Needle is array, check if haystack contains all items
        foreach ((array)$needle as $str_needle) {
            if (!empty($str_needle) && mb_strpos($haystack, $str_needle) === false) {
                return false;
            }
        }

        return true;
    }
1083698
public static function EndsWith($haystack, $needle)
    {
        $length = static::Length($needle);

        return $length === 0 || (substr($haystack, -$length) === $needle);
    }
1166152
public static function removePrefix($haystack, $prefix)
    {
        if (!is_string($haystack) || !is_string($prefix)) {
            throw new \InvalidArgumentException('Not a string');
        }

        if (strpos($haystack, $prefix) === 0) {
            $haystack = substr($haystack, strlen($prefix));
        }

        return $haystack;
    }
14261
private function _inArray($needle, $haystack) {
		foreach ($haystack as $strand) {
			if (fnmatch($strand, $needle)) {
				return true;
			}
		}
		return false;
	}
240637
public static function inArrayRecursive($needle, $haystack, $strict = false)
	{
		foreach ($haystack as $value)
		{
			if (! $strict and $needle == $value)
			{
				return true;
			}
			elseif ($needle === $value)
			{
				return true;
			}
			elseif (is_array($value) and static::inArrayRecursive($needle, $value, $strict))
			{
				return true;
			}
		}

		return false;
	}
1239455
public function in_multiarray($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if (is_array($value)) {
                if ($this->in_multiarray($needle, $value)) {
                    return true;
                }
            } else {
                if ($value == $needle) {
                    return true;
                }
            }
        }
        return false;
    }
454451
public static function inArray($needle, $haystack, $index)
    {
        foreach($haystack as $element)
        {
            if($element[$index] == $needle) return true;
        }
        return false;
    }
1244366
protected function _emptyValue($value)
    {
        if ($value === true) {
            return ['' => ''];
        }
        if (is_scalar($value)) {
            return ['' => $value];
        }
        if (is_array($value)) {
            return $value;
        }

        return [];
    }