Checks if a string ends with another one.

@param string $haystack The string to search in
@param string $needle   The string to search for

@return bool
199271
public function endsWith(string $haystack, string $needle): bool
    {
        $escaped = preg_quote($needle);

        return (bool) preg_match("/$escaped$/", $haystack);
    }
160644
private function endsWith($haystack, $needle)
    {
        $length = strlen($needle);
        if ($length === 0) {
            return true;
        }

        return substr($haystack, -$length) === $needle;
    }
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;
    }
310917
public static function substrInArray($needle, array $haystack)
    {
        $filtered = array_filter(
            $haystack,
            function($item) use ($needle) {
                return false !== strpos($item, $needle);
            }
        );

        /** @noinspection IsEmptyFunctionUsageInspection */
        return !empty($filtered);
    }
1109425
protected function strlikeInArray($needle, array $haystack)
    {
        if (isset($haystack["options"])) {
            $haystack = $haystack["options"];
        }
        foreach ($haystack as $value) {
            if (strpos($value, $needle) !== false) {
                return ($value);
            }
        }
        return (null);
    }
1340777
public static function contains( $haystack, $needles )
    {
        foreach ( ( array ) $needles as $needle )
        {
            if ( '' !== $needle && FALSE !== strpos( $haystack, $needle ) )
            {
                return TRUE;
            }
        }

        return FALSE;
    }
272412
public static function endsWith($haystack, $needle)
    {
        return $needle === '' or (($temp = mb_strlen($haystack) - mb_strlen($needle)) >= 0 and mb_strpos($haystack, $needle, $temp) !== false);
    }
794565
public static function exists(SimpleXMLElement $needle, SimpleXMLElement $haystack){
        foreach($haystack as $item){
            if($item->asXML() == $needle->asXML())
                return true;
        }
        return false;
    }
1156820
public static function strContains($needles, $haystack)
    {
        if (!is_array($needles)) {
            $needles = (array) $needles;
        }

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

        return false;
    }
620040
public static function stringEndsWith($haystack, $needle)
    {
        if (!is_string($haystack) || !is_string($needle)) {
            throw new \InvalidArgumentException('Not a string');
        }

        return (strrpos($haystack, $needle) + strlen($needle)) === strlen($haystack);
    }
623563
public static function subStringAfterLast($haystack, $needle, $n = 1)
    {
        $string = "";
        while ($n>0) {
            $string .= substr($haystack, strrpos($haystack, $needle) + 1);
            if($n>1){
                $string = $needle . $string;
            }
            $n--;
        }
        return $string;
    }
1285782
public static function startsWith($haystack, $needle) {
		if($needle === null && $haystack === null)
			return false;
		if($needle === null && $haystack !== null)
			return true;
		return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
	}
929985
public static function ends_with( $haystack, $needle ) {
        return ( substr( $haystack, strlen( $haystack ) - strlen( $needle ) ) == $needle );
    }
76339
public static function contains($haystack, $needles)
    {
        $needles = (array) $needles;

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

        return false;
    }
649501
public static function startsWith($haystack, $needle)
    {
        if (strlen($haystack) < strlen($needle)) {
            return false;
        }
        $start = substr($haystack, 0, strlen($needle));

        return $needle === "" || $needle === $start;
    }
975820
public static function arraySearchGetValue($needle, array $haystack)
    {
        $lcNeedle = strtolower($needle);

        foreach ($haystack as $value) {
            if ($lcNeedle == strtolower($value)) {
                return $value;
            }
        }

        return null;
    }
630345
public static function contains( $needle, $haystack, $strict = false )
    {
        foreach ( $haystack as $_index => $_value )
        {
            if ( is_string( $_value ) )
            {
                if ( 0 === strcasecmp( $needle, $_value ) )
                {
                    return true;
                }
            }
            else if ( in_array( $needle, $_value, $strict ) )
            {
                return true;
            }
        }

        return false;
    }