Skip to content

Commit 65a3fee

Browse files
rmunatermunatetaylorotwell
authored
[10.x] Add position method usage (#9063)
* Add position use * Adjust Order * Adjust Order * Adjust Order * formatting --------- Co-authored-by: rmunate <raulunatecastro@MacBook-Pro-de-Raul.local> Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 8bdce09 commit 65a3fee

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

strings.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Laravel includes a variety of functions for manipulating string values. Many of
6868
[Str::password](#method-str-password)
6969
[Str::plural](#method-str-plural)
7070
[Str::pluralStudly](#method-str-plural-studly)
71+
[Str::position](#method-str-position)
7172
[Str::random](#method-str-random)
7273
[Str::remove](#method-str-remove)
7374
[Str::repeat](#method-str-repeat)
@@ -158,6 +159,7 @@ Laravel includes a variety of functions for manipulating string values. Many of
158159
[padRight](#method-fluent-str-padright)
159160
[pipe](#method-fluent-str-pipe)
160161
[plural](#method-fluent-str-plural)
162+
[position](#method-fluent-str-position)
161163
[prepend](#method-fluent-str-prepend)
162164
[remove](#method-fluent-str-remove)
163165
[repeat](#method-fluent-str-repeat)
@@ -774,6 +776,21 @@ You may provide an integer as a second argument to the function to retrieve the
774776

775777
// VerifiedHuman
776778

779+
<a name="method-str-position"></a>
780+
#### `Str::position()` {.collection-method}
781+
782+
The `Str::position` method returns the position of the first occurrence of a substring in a string. If the substring does not exist in the given string, `false` is returned:
783+
784+
use Illuminate\Support\Str;
785+
786+
$position = Str::position('Hello, World!', 'Hello');
787+
788+
// 0
789+
790+
$position = Str::position('Hello, World!', 'W');
791+
792+
// 7
793+
777794
<a name="method-str-random"></a>
778795
#### `Str::random()` {.collection-method}
779796

@@ -1921,6 +1938,21 @@ You may provide an integer as a second argument to the function to retrieve the
19211938

19221939
// child
19231940

1941+
<a name="method-fluent-str-position"></a>
1942+
#### `position` {.collection-method}
1943+
1944+
The `position` method returns the position of the first occurrence of a substring in a string. If the substring does not exist within the string, `false` is returned:
1945+
1946+
use Illuminate\Support\Str;
1947+
1948+
$position = Str::of('Hello, World!')->position('Hello');
1949+
1950+
// 0
1951+
1952+
$position = Str::of('Hello, World!')->position('W');
1953+
1954+
// 7
1955+
19241956
<a name="method-fluent-str-prepend"></a>
19251957
#### `prepend` {.collection-method}
19261958

0 commit comments

Comments
 (0)