From f5999339dd502fdcbe1bc51ed7c0e7afca369c46 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Wed, 22 Mar 2023 13:32:56 +0300 Subject: [PATCH] Adding str_ends_with(..) --- helpers.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helpers.inc.php b/helpers.inc.php index f9394de..d0034f0 100644 --- a/helpers.inc.php +++ b/helpers.inc.php @@ -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); + } +}