Skip to content

Commit b10cf56

Browse files
authored
Merge pull request #5596 from kennith/updates/framework-pr-30507
[6.x] Document Str::afterLast() and Str::beforeLast()
2 parents 2ce2925 + af352f3 commit b10cf56

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

helpers.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
7878
[e](#method-e)
7979
[preg_replace_array](#method-preg-replace-array)
8080
[Str::after](#method-str-after)
81+
[Str::afterLast](#method-str-after-last)
8182
[Str::before](#method-str-before)
83+
[Str::beforeLast](#method-str-before-last)
8284
[Str::camel](#method-camel-case)
8385
[Str::contains](#method-str-contains)
8486
[Str::containsAll](#method-str-contains-all)
@@ -828,6 +830,17 @@ The `Str::after` method returns everything after the given value in a string:
828830

829831
// ' my name'
830832

833+
<a name="method-str-after-last"></a>
834+
#### `Str::afterLast()` {#collection-method}
835+
836+
The `Str::afterLast` method returns everything after the last occurrence of the given value in a string:
837+
838+
use Illuminate\Support\Str;
839+
840+
$slice = Str::afterLast('App\Http\Controllers\Controller', '\\');
841+
842+
// 'Controller'
843+
831844
<a name="method-str-before"></a>
832845
#### `Str::before()` {#collection-method}
833846

@@ -839,6 +852,17 @@ The `Str::before` method returns everything before the given value in a string:
839852

840853
// 'This is '
841854

855+
<a name="method-str-before-last"></a>
856+
#### `Str::beforeLast()` {#collection-method}
857+
858+
The `Str::beforeLast` method returns everything before the last occurrence of the given value in a string:
859+
860+
use Illuminate\Support\Str;
861+
862+
$slice = Str::beforeLast('This is my name', 'is');
863+
864+
// 'This '
865+
842866
<a name="method-camel-case"></a>
843867
#### `Str::camel()` {#collection-method}
844868

0 commit comments

Comments
 (0)