wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



str_ends_with › WordPress Function

Da5.9.0
Deprecaton/a
str_ends_with ( $haystack, $needle )
Parametri: (2)
  • (string) $haystack The string to search in.
    Richiesto:
  • (string) $needle The substring to search for in the `$haystack`.
    Richiesto:
Ritorna:
  • (bool) True if `$haystack` ends with `$needle`, otherwise false.
Definito a:
Codex:

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

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


Sorgenti

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

		$len = strlen( $needle );

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