This function works similar to the corresponding .net / Java function.

@param string $haystack
@param string $needle
@return bool True if $haystack ends with $needle or if $needle is a empty string
516855
public static function endsWith($haystack, $needle)
    {
        if (strlen($haystack) < strlen($needle)) {
            return false;
        }
        $end = substr($haystack, strlen($haystack) - strlen($needle), strlen($needle));

        return $needle === "" || $needle === $end;
    }
199271
public function endsWith(string $haystack, string $needle): bool
    {
        $escaped = preg_quote($needle);

        return (bool) preg_match("/$escaped$/", $haystack);
    }
1003507
public static function contains(string $haystack, string $needle, int $offset = 0): bool
    {
        return self::strpos($haystack, $needle, $offset) !== false;
    }
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);
    }
324604
public static function contains($haystack, $needle, $ignoreCase = false)
    {
        if ($ignoreCase) {
            $needle = strtolower($needle);
            $haystack = strtolower($haystack);
        }
        $pos = strpos($haystack, $needle);

        return !($pos === 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;
	}
374853
public static function checkIfContainsAnyOf($haystack, $needles) {
		foreach ($needles as $needle) {
			if (self::checkIfContains($haystack, $needle)) return true;
		}
		return false;
	}
568917
public static function startWith(string $haystack, string $needle): bool
    {
        return ($needle === mb_substr($haystack, 0, mb_strlen($needle, 'UTF-8'), 'UTF-8'));
    }
1190505
public function beginsWith(string $haystack, string $needle): bool
    {
        return (!empty($needle) && 0 === strpos($haystack, $needle));
    }
829816
public static function endsWith($haystack, $needle)
    {
        $hl = strlen($haystack);
        $nl = strlen($needle);
        if(substr($haystack, $hl-$nl, $hl) == $needle)
            return true;

        return false;
    }
441400
public static function startsWith($haystack, $needle)
    {
        $length = strlen($needle);

        return substr($haystack, 0, $length) === $needle;
    }
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);
    }
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;
    }
138235
public static function contains($haystack, $needle)
    {
        foreach ((array)$needle as $n) {
            if (strpos($haystack, $n) !== false) {
                return true;
            }
        }

        return false;
    }
29815
protected function fileEndsWith(string $haystack, string $needle): bool
    {
        $length = strlen($needle);
        if (strlen($haystack) < $length) {
            return $this->fileEndsWith($needle, $haystack);
        }

        $haystack = str_replace('\\', '/', $haystack);
        $needle = str_replace('\\', '/', $needle);
        
        return (substr($haystack, -$length) === $needle);
    }
430217
protected function contains($needle, $haystackId)
    {
        $deps = $this->getDependencies($haystackId);
        if (!is_array($deps)) {
            return false;
        }

        return in_array($needle, $deps);
    }
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));
	}