Checks if at least one item from haystack ends with needle

@param string $needle
@param array  $haystack

@return bool
551642
public function endWithFunction($needle, $haystack = [])
    {
        if (in_array($needle, $haystack)) {
            return true;
        } else {
            foreach ($haystack as $item) {
                $length = strlen($needle);
                if (substr($haystack, -$length) === $needle) {
                    return true;
                }
            }
        }

        return false;
    }
581645
public function startWithFunction($needle, $haystack = [])
    {
        if (in_array($needle, $haystack)) {
            return true;
        } else {
            foreach ($haystack as $item) {
                if (strpos($needle, $item) === 0) {
                    return true;
                }
            }
        }

        return false;
    }
1190505
public function beginsWith(string $haystack, string $needle): bool
    {
        return (!empty($needle) && 0 === strpos($haystack, $needle));
    }
840096
public static function startsWith($haystack, $needles)
    {
        $needles = (array) $needles;

        foreach ($needles as $needle) {
            if ($needle && strpos($haystack, $needle) === 0) {
                return true;
            }
        }

        return false;
    }
887610
public static function getStartBeforeLast(string $haystack, string $needle)
    {
        $end = self::getEndAfterLast($haystack, $needle);
        $length = -1 * (strlen($end) + strlen($needle));
        return substr($haystack, 0, $length);
    }
742125
public static function stringBeginsWith($haystack, $needle)
    {
        if (!empty($needle) && strncmp($haystack, $needle, strlen($needle)) === 0) {
            return true;
        }

        return false;
    }
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;
    }
702805
public static function containsAll($haystack, array $needles)
    {
        foreach ($needles as $needle) {
            if ($needle != '' && mb_strpos($haystack, $needle) === false) {
                return false;
            }
        }

        return true;
    }
801148
protected function wasDispatched($needle, array $haystack)
    {
        foreach ($haystack as $dispatched) {
            if ((is_string($dispatched) && ($dispatched === $needle || is_subclass_of($dispatched, $needle))) ||
                $dispatched instanceof $needle) {
                return true;
            }
        }

        return false;
    }
929985
public static function ends_with( $haystack, $needle ) {
        return ( substr( $haystack, strlen( $haystack ) - strlen( $needle ) ) == $needle );
    }
1312080
public static function has(string $needle, string $haystack): bool
    {
        return $needle === '' || strpos($haystack, $needle) !== false;
    }
336789
public static function endsWith( $haystack, $needle )
	{
		$strlen = strlen( $haystack );
		$testlen = strlen( $needle );
		if ( $testlen > $strlen ) return false;
		return substr_compare( $haystack, $needle, $strlen - $testlen, $testlen ) === 0;
	}
905528
public static function ends($haystack, $needle, $caseSensitive = false): bool
    {
        if ($caseSensitive === true) {
            return $needle === '' || mb_substr($haystack, -mb_strlen($needle)) === $needle;
        }
        $haystack = mb_strtolower($haystack);
        $needle = mb_strtolower($needle);

        return $needle === '' || mb_substr($haystack, -mb_strlen($needle)) === $needle;
    }
1059153
public static function contains(string $haystack, string $needle, bool $caseSensitive = true)
    {
        if ($caseSensitive) {
            return $needle === '' || strpos($haystack, $needle) !== false;
        }

        return $needle === '' || stripos($haystack, $needle) !== false;
    }
783606
public static function getEndAfterLast(string $haystack, string $needle) : string
    {
        $lastOccurence = strrchr($haystack, $needle);
        if ($lastOccurence === false) {
            return $haystack;
        }
        return ltrim(strrchr($haystack, $needle), $needle);
    }
125521
protected function hasPostFix($haystack, $needles)
    {
        if (!is_array($needles)) {
            $needles = [$needles];
        }

        foreach ($needles as $needle) {
            if ($haystack === $needle || Str::endsWith($haystack, ucfirst($needle))) {
                return true;
            }
        }

        return false;
    }
1215036
protected function in_array($needle, $haystack)
    {
        return count(array_filter($haystack, function ($hay) use ($needle) {
            return $hay === $needle;
        })) > 0;
    }