Adding str_ends_with(..)

This commit is contained in:
Pavel Shevaev 2023-03-22 13:32:56 +03:00
parent e34f22a06b
commit f5999339dd
1 changed files with 8 additions and 0 deletions

View File

@ -1163,3 +1163,11 @@ function arg_exists($args, $needle)
return in_array($needle, $args, $strict);
}
if(!function_exists('str_ends_with'))
{
function str_ends_with($haystack, $needle)
{
// search forward starting from end minus needle length characters
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false);
}
}