Checks if value ends with a search string

@param mixed  $value    The value
@param string $search   The search string
@param string $encoding The string encoding

@return bool
326370
public static function endsWith($value, string $search, string $encoding = 'UTF-8'): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        $searchlen = (int) mb_strlen($search, $encoding);
        $length = (int) mb_strlen((string) $value, $encoding);
        $end = mb_substr((string) $value, $length - $searchlen, $searchlen, $encoding);

        return $search === $end;
    }
1029931
public function checkValue(&$value)
    {
        if (parent::checkValue($value)) {
            $value = trim($value, " \r\n\t\f;");

            // Check if declaration contains "!important"
            if (strpos($value, "!") !== false) {
                $charset = $this->getStyleSheet()->getCharset();
                if (mb_strtolower(mb_substr($value, -10, null, $charset), $charset) === "!important") {
                    $this->setIsImportant(true);
                    $value = rtrim(mb_substr($value, 0, -10, $charset));
                }
            }

            // Optimize the value
            $value = Optimizer::optimizeDeclarationValue($value);

            return true;
        }

        return false;
    }
1050849
public static function rangeLength($value, int $minLength, int $maxLength, string $encoding = 'UTF-8'): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        $strlen = (int) mb_strlen((string) $value, $encoding);

        if ($strlen < $minLength) {
            return false;
        }
        if ($strlen > $maxLength) {
            return false;
        }

        return true;
    }
741326
public function extract($end = false)
    {
        /**
         * The last parsed position.
         *
         * This is statically defined because it is not used outside anywhere
         * outside this method and there is probably a (minor) performance
         * improvement to it.
         *
         * @var int
         */
        static $i = 0;

        if (empty($this->query)) {
            return false;
        }

        /**
         * The length of the buffer.
         *
         * @var int
         */
        $len = strlen($this->query);

        /**
         * The last index of the string that is going to be parsed.
         *
         * There must be a few characters left in the buffer so the parser can
         * avoid confusing some symbols that may have multiple meanings.
         *
         * For example, if the buffer ends in `-` that may be an operator or the
         * beginning of a comment.
         *
         * Another example if the buffer ends in `DELIMITE`. The parser is going
         * to require a few more characters because that may be a part of the
         * `DELIMITER` keyword or just a column named `DELIMITE`.
         *
         * Those extra characters are required only if there is more data
         * expected (the end of the buffer was not reached).
         *
         * @var int
         */
        $loopLen = $end ? $len : $len - 16;

        for (; $i < $loopLen; ++$i) {
            /*
             * Handling backslash.
             *
             * Even if the next character is a special character that should be
             * treated differently, because of the preceding backslash, it will
             * be ignored.
             */
            if ((($this->status & static::STATUS_COMMENT) === 0) && ($this->query[$i] === '\\')) {
                $this->current .= $this->query[$i] . $this->query[++$i];
                continue;
            }

            /*
             * Handling special parses statuses.
             */
            if ($this->status === static::STATUS_STRING_SINGLE_QUOTES) {
                // Single-quoted strings like 'foo'.
                if ($this->query[$i] === '\'') {
                    $this->status = 0;
                }
                $this->current .= $this->query[$i];
                continue;
            } elseif ($this->status === static::STATUS_STRING_DOUBLE_QUOTES) {
                // Double-quoted strings like "bar".
                if ($this->query[$i] === '"') {
                    $this->status = 0;
                }
                $this->current .= $this->query[$i];
                continue;
            } elseif ($this->status === static::STATUS_STRING_BACKTICK) {
                if ($this->query[$i] === '`') {
                    $this->status = 0;
                }
                $this->current .= $this->query[$i];
                continue;
            } elseif (($this->status === static::STATUS_COMMENT_BASH)
                || ($this->status === static::STATUS_COMMENT_SQL)
            ) {
                // Bash-like (#) or SQL-like (-- ) comments end in new line.
                if ($this->query[$i] === "\n") {
                    $this->status = 0;
                }
                $this->current .= $this->query[$i];
                continue;
            } elseif ($this->status === static::STATUS_COMMENT_C) {
                // C-like comments end in */.
                if (($this->query[$i - 1] === '*') && ($this->query[$i] === '/')) {
                    $this->status = 0;
                }
                $this->current .= $this->query[$i];
                continue;
            }

            /*
             * Checking if a string started.
             */
            if ($this->query[$i] === '\'') {
                $this->status = static::STATUS_STRING_SINGLE_QUOTES;
                $this->current .= $this->query[$i];
                continue;
            } elseif ($this->query[$i] === '"') {
                $this->status = static::STATUS_STRING_DOUBLE_QUOTES;
                $this->current .= $this->query[$i];
                continue;
            } elseif ($this->query[$i] === '`') {
                $this->status = static::STATUS_STRING_BACKTICK;
                $this->current .= $this->query[$i];
                continue;
            }

            /*
             * Checking if a comment started.
             */
            if ($this->query[$i] === '#') {
                $this->status = static::STATUS_COMMENT_BASH;
                $this->current .= $this->query[$i];
                continue;
            } elseif ($i + 2 < $len) {
                if (($this->query[$i] === '-')
                 && ($this->query[$i + 1] === '-')
                 && Context::isWhitespace($this->query[$i + 2])) {
                    $this->status = static::STATUS_COMMENT_SQL;
                    $this->current .= $this->query[$i];
                    continue;
                } elseif (($this->query[$i] === '/')
                 && ($this->query[$i + 1] === '*')
                 && ($this->query[$i + 2] !== '!')) {
                    $this->status = static::STATUS_COMMENT_C;
                    $this->current .= $this->query[$i];
                    continue;
                }
            }

            /*
             * Handling `DELIMITER` statement.
             *
             * The code below basically checks for
             *     `strtoupper(substr($this->query, $i, 9)) === 'DELIMITER'`
             *
             * This optimization makes the code about 3 times faster.
             *
             * `DELIMITER` is not being considered a keyword. The only context
             * it has a special meaning is when it is the beginning of a
             * statement. This is the reason for the last condition.
             */
            if (($i + 9 < $len)
                && (($this->query[$i] === 'D') || ($this->query[$i] === 'd'))
                && (($this->query[$i + 1] === 'E') || ($this->query[$i + 1] === 'e'))
                && (($this->query[$i + 2] === 'L') || ($this->query[$i + 2] === 'l'))
                && (($this->query[$i + 3] === 'I') || ($this->query[$i + 3] === 'i'))
                && (($this->query[$i + 4] === 'M') || ($this->query[$i + 4] === 'm'))
                && (($this->query[$i + 5] === 'I') || ($this->query[$i + 5] === 'i'))
                && (($this->query[$i + 6] === 'T') || ($this->query[$i + 6] === 't'))
                && (($this->query[$i + 7] === 'E') || ($this->query[$i + 7] === 'e'))
                && (($this->query[$i + 8] === 'R') || ($this->query[$i + 8] === 'r'))
                && Context::isWhitespace($this->query[$i + 9])
            ) {
                // Saving the current index to be able to revert any parsing
                // done in this block.
                $iBak = $i;
                $i += 9; // Skipping `DELIMITER`.

                // Skipping whitespaces.
                while (($i < $len) && Context::isWhitespace($this->query[$i])) {
                    ++$i;
                }

                // Parsing the delimiter.
                $delimiter = '';
                while (($i < $len) && (! Context::isWhitespace($this->query[$i]))) {
                    $delimiter .= $this->query[$i++];
                }

                // Checking if the delimiter definition ended.
                if (($delimiter !== '')
                    && ((($i < $len) && Context::isWhitespace($this->query[$i]))
                    || (($i === $len) && $end))
                ) {
                    // Saving the delimiter.
                    $this->setDelimiter($delimiter);

                    // Whether this statement should be returned or not.
                    $ret = '';
                    if (! empty($this->options['parse_delimiter'])) {
                        // Appending the `DELIMITER` statement that was just
                        // found to the current statement.
                        $ret = trim(
                            $this->current . ' ' . substr($this->query, $iBak, $i - $iBak)
                        );
                    }

                    // Removing the statement that was just extracted from the
                    // query.
                    $this->query = substr($this->query, $i);
                    $i = 0;

                    // Resetting the current statement.
                    $this->current = '';

                    return $ret;
                }

                // Incomplete statement. Reverting
                $i = $iBak;

                return false;
            }

            /*
             * Checking if the current statement finished.
             *
             * The first letter of the delimiter is being checked as an
             * optimization. This code is almost as fast as the one above.
             *
             * There is no point in checking if two strings match if not even
             * the first letter matches.
             */
            if (($this->query[$i] === $this->delimiter[0])
                && (($this->delimiterLen === 1)
                || (substr($this->query, $i, $this->delimiterLen) === $this->delimiter))
            ) {
                // Saving the statement that just ended.
                $ret = $this->current;

                // If needed, adds a delimiter at the end of the statement.
                if (! empty($this->options['add_delimiter'])) {
                    $ret .= $this->delimiter;
                }

                // Removing the statement that was just extracted from the
                // query.
                $this->query = substr($this->query, $i + $this->delimiterLen);
                $i = 0;

                // Resetting the current statement.
                $this->current = '';

                // Returning the statement.
                return trim($ret);
            }

            /*
             * Appending current character to current statement.
             */
            $this->current .= $this->query[$i];
        }

        if ($end && ($i === $len)) {
            // If the end of the buffer was reached, the buffer is emptied and
            // the current statement that was extracted is returned.
            $ret = $this->current;

            // Emptying the buffer.
            $this->query = '';
            $i = 0;

            // Resetting the current statement.
            $this->current = '';

            // Returning the statement.
            return trim($ret);
        }

        return '';
    }
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;
	}
1305625
public static function endsWith($haystack, $needle)
    {
        return $needle == substr($haystack, strlen($haystack) - strlen($needle));
    }
257758
public static function isEnd($haystack, $needle, $caseSensitive = false): bool
    {
        if ($caseSensitive) {
            return $needle === '' || self::sub($haystack, -self::len($needle)) === $needle;
        }

        $haystack = self::low($haystack);
        $needle = self::low($needle);

        return $needle === '' || self::sub($haystack, -self::len($needle)) === $needle;
    }
1209835
public static function removeRight($string, $search, $encoding = null)
    {
        if ($string === '') {
            return '';
        }

        if ($search === '') {
            return $string;
        }

        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        if (!static::endsWith($string, $search, true, $encoding)) {
            return $string;
        }

        return Mbstring::substr($string, 0, -Mbstring::strlen($search), $encoding);
    }
699908
function endsWith(target, searchString, position) {
  position = position || target.length;
  position = position - searchString.length;
  let lastIndex = target.lastIndexOf(searchString);
  return lastIndex !== -1 && lastIndex === position;
}
1010896
public static function  endsWith( $haystack , $needle )
	{
		return $needle === "" || ( ( $temp = strlen( $haystack ) - strlen( $needle ) ) >= 0 && strpos( $haystack , $needle , $temp ) !== false );
	}
535933
public static function endWith($value, $comparable)
    {
        if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) {
            return false;
        }
        
        if (preg_match("/$comparable$/", $value)) {
            return true;
        }

        return false;
    }
160903
public function find( $search ) {

		if ( ! is_array( $search ) ) {
			$search = (array) $search;
		}

		foreach ( $search as $val ) {
			if ( $this->fulltextSearchInPost( $val ) !== false ) {
				return true;
			}
			if ( $this->fulltextSearchInMeta( $val ) !== false ) {
				return true;
			}
		}

		return false;
	}
1151173
public static function endsWith($value, $end)
    {
        if (is_array($value)) {
            return self::last($value) == $end;
        }

        $end = "$end";

        return substr($value, -strlen($end)) === $end;
    }
1368422
private function validate($encoded): bool
    {
        // Check for existence of the prefix
        if (strpos($encoded, self::punycodePrefix) !== 0) {
            return false;
        }

        // If nothing is left after the prefix, it is hopeless
        if (strlen(trim($encoded)) <= strlen(self::punycodePrefix)) {
            return false;
        }

        return true;
    }
1293537
public function endswith(string $haystack, string $needle) : bool
    {
        return (substr($haystack, -1 * strlen($needle)) === $needle);
    }
1284029
public function isCharset($string, $encoding)
    {
        return strtoupper($this->detect($string, [], true)) == strtoupper($encoding);
    }
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;
    }