wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



str_ends_with › WordPress Function

Desde5.9.0
Obsoleton/a
str_ends_with ( $haystack, $needle )
Parâmetros: (2)
  • (string) $haystack The string to search in.
    Required: Yes
  • (string) $needle The substring to search for in the `$haystack`.
    Required: Yes
Retorna:
  • (bool) True if `$haystack` ends with `$needle`, otherwise false.
Definido em:
Codex:

Polyfill for `str_ends_with()` function added in PHP 8.0.

Performs a case-sensitive check indicating if the haystack ends with needle.


Fonte

function str_ends_with( $haystack, $needle ) {
		if ( '' === $haystack ) {
			return '' === $needle;
		}

		$len = strlen( $needle );

		return substr( $haystack, -$len, $len ) === $needle;
	}
}