Skip to content

Commit 11c80bf

Browse files
authored
Merge pull request #20059 from salehhashemi1992/feature/optimize-findBetween-method
Optimize findBetween method (remove calling function mb_substr())
2 parents 6804fbe + 5ce3b4e commit 11c80bf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

framework/helpers/BaseStringHelper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,14 +546,13 @@ public static function findBetween($string, $start, $end)
546546
return null;
547547
}
548548

549-
// Cut the string from the start position
550-
$subString = mb_substr($string, $startPos + mb_strlen($start));
551-
$endPos = mb_strrpos($subString, $end);
549+
$startPos += mb_strlen($start);
550+
$endPos = mb_strrpos($string, $end, $startPos);
552551

553552
if ($endPos === false) {
554553
return null;
555554
}
556555

557-
return mb_substr($subString, 0, $endPos);
556+
return mb_substr($string, $startPos, $endPos - $startPos);
558557
}
559558
}

0 commit comments

Comments
 (0)