Skip to content

Commit cdf384e

Browse files
Add documentation for charAt(). (#9134)
* Add documentation for charAt(). * Update strings.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent b8a2d8f commit cdf384e

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

strings.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Laravel includes a variety of functions for manipulating string values. Many of
4141
[Str::between](#method-str-between)
4242
[Str::betweenFirst](#method-str-between-first)
4343
[Str::camel](#method-camel-case)
44+
[Str::charAt](#method-char-at)
4445
[Str::contains](#method-str-contains)
4546
[Str::containsAll](#method-str-contains-all)
4647
[Str::endsWith](#method-ends-with)
@@ -124,6 +125,7 @@ Laravel includes a variety of functions for manipulating string values. Many of
124125
[between](#method-fluent-str-between)
125126
[betweenFirst](#method-fluent-str-between-first)
126127
[camel](#method-fluent-str-camel)
128+
[charAt](#method-fluent-str-char-at)
127129
[classBasename](#method-fluent-str-class-basename)
128130
[contains](#method-fluent-str-contains)
129131
[containsAll](#method-fluent-str-contains-all)
@@ -340,7 +342,19 @@ The `Str::camel` method converts the given string to `camelCase`:
340342

341343
$converted = Str::camel('foo_bar');
342344

343-
// fooBar
345+
// 'fooBar'
346+
347+
<a name="method-char-at"></a>
348+
349+
#### `Str::charAt()` {.collection-method}
350+
351+
The `Str::charAt` method returns the character at the specified index. If the index is out of bounds, `false` is returned:
352+
353+
use Illuminate\Support\Str;
354+
355+
$character = Str::charAt('This is my name.', 6);
356+
357+
// 's'
344358

345359
<a name="method-str-contains"></a>
346360
#### `Str::contains()` {.collection-method}
@@ -1394,7 +1408,18 @@ The `camel` method converts the given string to `camelCase`:
13941408

13951409
$converted = Str::of('foo_bar')->camel();
13961410

1397-
// fooBar
1411+
// 'fooBar'
1412+
1413+
<a name="method-fluent-str-char-at"></a>
1414+
#### `charAt` {.collection-method}
1415+
1416+
The `charAt` method returns the character at the specified index. If the index is out of bounds, `false` is returned:
1417+
1418+
use Illuminate\Support\Str;
1419+
1420+
$character = Str::of('This is my name.')->charAt(6);
1421+
1422+
// 's'
13981423

13991424
<a name="method-fluent-str-class-basename"></a>
14001425
#### `classBasename` {.collection-method}
@@ -1405,7 +1430,7 @@ The `classBasename` method returns the class name of the given class with the cl
14051430

14061431
$class = Str::of('Foo\Bar\Baz')->classBasename();
14071432

1408-
// Baz
1433+
// 'Baz'
14091434

14101435
<a name="method-fluent-str-contains"></a>
14111436
#### `contains` {.collection-method}

0 commit comments

Comments
 (0)