Skip to content

Commit

Permalink
refactor findBetween method to remove calling function mb_substr()
Browse files Browse the repository at this point in the history
  • Loading branch information
salehhashemi1992 committed Nov 1, 2023
1 parent af6886f commit c544d77
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,15 +637,14 @@ public static function findBetween(string $string, string $start, string $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);
}

/**
Expand Down

0 comments on commit c544d77

Please sign in to comment.