remove value from array / does not reindex

@param array   $haystack array
@param mixed   $needle   value to remove from array
@param boolean $strict   true

@return integer removed count
546387
public static function removeVal(&$haystack, $needle, $strict = true)
    {
        $count = 0;
        if (\is_array($haystack)) {
            // PHP 4 doesn't have 3rd array_keys() param -> perform strict check in loop
            $keys = \array_keys($haystack, $needle);
            foreach ($keys as $k) {
                if ($strict && $haystack[$k] !== $needle) {
                    continue;
                }
                unset($haystack[$k]);
                $count++;
            }
        }
        return $count;
    }
211391
public function has($needle, bool $strict = true): bool
    {
        foreach ($this->values as $value) {
            if ($strict && $value === $needle) {
                return true;
            }

            if ($strict && $value == $needle) {
                return true;
            }
        }

        return false;
    }
828023
protected function in_array_recursive( $needle, $haystack ) {
		foreach ( $haystack as $type => $v ) {
			if ( $needle === $v ) { // Useful for recursion only.
				return true;
			} elseif ( is_array( $v ) ) {
				// Basically checks only the version value.
				if ( in_array( $needle, $v, true ) ) {
					return true;
				}

				// Now, time for recursion.
				if ( ! $this->in_array_recursive( $needle, $v ) ) {
					continue;
				} else {
					return true;
				}
			}
		}

		return false;
	}
3536
protected function inArray(array $needle, array $haystack) {
        // Loop over all the values in the needle array, and make sure each and every one is in some
        // way present in the haystack, in a recursive manner.
        foreach ($needle as $needleValue) {
            if (is_array($needleValue)) {
                // If the value is an array we need to do a recursive compare / inArray check
                if ($this->arrayIsList($needleValue)) {
                    // The needle value is a list, so we only want to compare it to lists in the
                    // haystack
                    $listElementsInHaystack = array_filter($haystack, function($element) {
                        return is_array($element) && $this->arrayIsList($element);
                    });

                    if (empty($listElementsInHaystack)) {
                        throw new ArrayContainsComparatorException(
                            'Haystack does not contain any list elements, needle can\'t be found.', 0, null,
                            $needleValue, $haystack
                        );
                    }

                    $result = array_filter($listElementsInHaystack, function ($haystackListElement) use ($needleValue) {
                        try {
                            return $this->inArray($needleValue, $haystackListElement);
                        } catch (ArrayContainsComparatorException $e) {
                            // If any error occurs, swallow it and return false to mark this as a
                            // failure
                            return false;
                        }
                    });

                    // Result is empty, which means the needle was not found in the haystack
                    if (empty($result)) {
                        throw new ArrayContainsComparatorException(
                            'The list in needle was not found in the list elements in the haystack.', 0, null,
                            $needleValue, $haystack
                        );
                    }
                } else {
                    // The needle value is an object, so we only want to compare it to objects in
                    // the haystack
                    $objectElementsInHaystack = array_filter($haystack, function($element) {
                        return is_array($element) && $this->arrayIsObject($element);
                    });

                    if (empty($objectElementsInHaystack)) {
                        throw new ArrayContainsComparatorException(
                            'Haystack does not contain any object elements, needle can\'t be found.', 0, null,
                            $needleValue, $haystack
                        );
                    }

                    $result = array_filter($objectElementsInHaystack, function ($haystackObjectElement) use ($needleValue) {
                        try {
                            return $this->compare($needleValue, $haystackObjectElement);
                        } catch (ArrayContainsComparatorException $e) {
                            // If any error occurs, swallow it and return false to mark this as a
                            // failure
                            return false;
                        }
                    });

                    // Result is empty, which means the needle was not found in the haystack
                    if (empty($result)) {
                        throw new ArrayContainsComparatorException(
                            'The object in needle was not found in the object elements in the haystack.', 0, null,
                            $needleValue, $haystack
                        );
                    }
                }
            } else {
                $result = array_map(function($haystackElement) use ($needleValue) {
                    return $this->compareValues($needleValue, $haystackElement);
                }, $haystack);

                if (empty(array_filter($result))) {
                    throw new ArrayContainsComparatorException(
                        'Needle is not present in the haystack.', 0, null,
                        $needleValue, $haystack
                    );
                }
            }
        }

        // All's right with the world!
        return true;
    }
1310778
public static function in($needle, ?array $haystack = null, bool $strict = true): bool
    {
        // prevent errors
        if (!Any::isArray($haystack) || $needle === null) {
            return false;
        }

        return in_array($needle, $haystack, $strict);
    }
430217
protected function contains($needle, $haystackId)
    {
        $deps = $this->getDependencies($haystackId);
        if (!is_array($deps)) {
            return false;
        }

        return in_array($needle, $deps);
    }
1360988
public static function unsetInArrayByValue($needle, array $haystack, $reIndex = true)
    {
        $doReindex = false;

        foreach($haystack as $key => $value) {
            if (is_array($value)) {
                $haystack[$key] = static::unsetInArrayByValue($needle, $value);
            } else if ($needle === $value) {

                unset($haystack[$key]);

                if ($reIndex) {
                    $doReindex = true;
                }
            }
        }

        if ($doReindex) {
            $haystack = array_values($haystack);
        }

        return $haystack;
    }
550576
public static function recursivelySetValue($needleKey, $needleValue,
                                               array &$haystack)
    {
        foreach ($haystack as $key => &$value) {
            if (isset($haystack[$needleKey])) {
                $haystack[$needleKey] = $needleValue;
            }

            if (is_array($value)) {
                self::recursivelySetValue($needleKey, $needleValue, $value);
            }
        }
    }
234733
static function endsWith($haystack, $needles, $strict = true)
    {
        // 不区分大小写的情况下 全部转为小写
        if (!$strict) $haystack = mb_strtolower($haystack);

        // 支持以数组方式传入 needles 检查多个字符串
        foreach ((array)$needles as $needle) {
            if (!$strict) $needle = mb_strtolower($needle);
            if ((string)$needle === mb_substr($haystack, -mb_strlen($needle))) {
                return true;
            }
        }
        return false;
    }
1180209
public static function containsOneOf($haystack, array $needles)
    {
        foreach ($needles as $needle) {
            if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
                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;
    }
1045059
public static function hasAllValuesMultiDimensional(array $haystack, array $needles)
    {
        $return = true;
        foreach ($needles as $needle) {
            if (!in_array($needle, $haystack)) {
                $return = false;
                break;
            }
        }

        return $return;
    }
1264102
public static function endsWith(
        string $haystack,
        string $needle,
        bool $caseSensitive = false
    ): bool
    {
        $test = substr($haystack, -strlen($needle));
        return ($caseSensitive === false)
            ? strcasecmp($test, $needle) === 0
            : strcmp($test, $needle) === 0;
    }
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;
	}
266365
public static function endWith(string $haystack, string $needle): bool
    {
        return ($needle === mb_substr($haystack, -mb_strlen($needle, 'UTF-8'), null, 'UTF-8'));
    }
311057
public static function recursiveArraySearch($needleKey, $needleValue,
                                                array $haystack)
    {
        foreach ($haystack as $key => $value) {
            $currentKey = $key;

            if (($currentKey == $needleKey && ($needleValue === null || $needleValue
                == $value)) || ( is_array($value) && self::recursiveArraySearch($needleKey,
                    $needleValue, $value) !== false)) {
                return $currentKey;
            }
        }
        return null;
    }
1013213
protected function stringHasStatement( $haystack, $needle ) {
		$pattern = '~^\s*(' . preg_quote( $needle, '~' ) . ')\s*$~m';
		return (bool) preg_match( $pattern, $haystack );
	}