Optimize findBetween method to remove calling function mb_substr()

This commit is contained in:
salehhashemi1992
2023-11-01 15:04:32 +03:30
parent 6804fbeae8
commit 5ce3b4ea01

View File

@ -546,14 +546,13 @@ class BaseStringHelper
return null; return null;
} }
// Cut the string from the start position $startPos += mb_strlen($start);
$subString = mb_substr($string, $startPos + mb_strlen($start)); $endPos = mb_strrpos($string, $end, $startPos);
$endPos = mb_strrpos($subString, $end);
if ($endPos === false) { if ($endPos === false) {
return null; return null;
} }
return mb_substr($subString, 0, $endPos); return mb_substr($string, $startPos, $endPos - $startPos);
} }
} }