Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Str::afterLast() and Str::beforeLast() helpers #30507

Merged
merged 2 commits into from
Nov 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update Str.php
  • Loading branch information
taylorotwell authored Nov 4, 2019
commit d7f0c0900b010973db24b5c47f33d28d1bd0d776
7 changes: 4 additions & 3 deletions src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ public static function beforeLast($subject, $search)
return $subject;
}

$rpos = mb_strrpos($subject, $search);
if ($rpos === false) {
$pos = mb_strrpos($subject, $search);

if ($pos === false) {
return $subject;
}

return static::substr($subject, 0, $rpos);
return static::substr($subject, 0, $pos);
}

/**
Expand Down