← All built-ins / str_ends_with()

str_ends_with()

str_ends_with(string $haystack, string $needle): bool

Parameters

NameTypeDescription
$haystackstringstring to test
$needlestringrequired suffix

Return value

true when $haystack ends with $needle.

Example

var_dump(str_ends_with("holy.php", ".php"));
var_dump(str_ends_with("holy.php", "holy"));
bool(true)
bool(false)

See also

str_starts_with()pathinfo()