Skip to content

Commit

Permalink
Merge pull request #20059 from salehhashemi1992/feature/optimize-find…
Browse files Browse the repository at this point in the history
…Between-method

Optimize findBetween method (remove calling function mb_substr())
  • Loading branch information
bizley authored Nov 2, 2023
2 parents 6804fbe + 5ce3b4e commit 11c80bf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions framework/helpers/BaseStringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,13 @@ public static function findBetween($string, $start, $end)
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);
}
}

0 comments on commit 11c80bf

Please sign in to comment.