From 5ce3b4ea01a55a2ecabd82ee5f62415d487c3c14 Mon Sep 17 00:00:00 2001 From: salehhashemi1992 <81674631+salehhashemi1992@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:04:32 +0330 Subject: [PATCH] Optimize findBetween method to remove calling function mb_substr() --- framework/helpers/BaseStringHelper.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/framework/helpers/BaseStringHelper.php b/framework/helpers/BaseStringHelper.php index 21a1f9e643..749f92f79c 100644 --- a/framework/helpers/BaseStringHelper.php +++ b/framework/helpers/BaseStringHelper.php @@ -546,14 +546,13 @@ class BaseStringHelper return null; } - // Cut the string from the start position - $subString = mb_substr($string, $startPos + mb_strlen($start)); - $endPos = mb_strrpos($subString, $end); + $startPos += mb_strlen($start); + $endPos = mb_strrpos($string, $end, $startPos); if ($endPos === false) { return null; } - return mb_substr($subString, 0, $endPos); + return mb_substr($string, $startPos, $endPos - $startPos); } }