Skip to content

Commit 5ce3b4e

Browse files
Optimize findBetween method to remove calling function mb_substr()
1 parent 6804fbe commit 5ce3b4e

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)