Skip to content

Commit f7d0b43

Browse files
committed
Merge pull request laravel#1278 from Jakobud/feature/doc/strings
Added output from examples to String documentation
2 parents d089046 + e67ddd8 commit f7d0b43

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

laravel/documentation/strings.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,29 @@
1414
The **Str** class also provides three convenient methods for manipulating string capitalization: **upper**, **lower**, and **title**. These are more intelligent versions of the PHP [strtoupper](http://php.net/manual/en/function.strtoupper.php), [strtolower](http://php.net/manual/en/function.strtolower.php), and [ucwords](http://php.net/manual/en/function.ucwords.php) methods. More intelligent because they can handle UTF-8 input if the [multi-byte string](http://php.net/manual/en/book.mbstring.php) PHP extension is installed on your web server. To use them, just pass a string to the method:
1515

1616
echo Str::lower('I am a string.');
17+
// i am a string.
1718

1819
echo Str::upper('I am a string.');
20+
// I AM A STRING.
1921

2022
echo Str::title('I am a string.');
23+
// I Am A String.
2124

2225
<a name="limits"></a>
2326
## Word & Character Limiting
2427

2528
#### Limiting the number of characters in a string:
2629

27-
echo Str::limit($string, 10);
28-
echo Str::limit_exact($string, 10);
30+
echo Str::limit("Lorem ipsum dolor sit amet", 10);
31+
// Lorem ipsu...
32+
33+
echo Str::limit_exact("Lorem ipsum dolor sit amet", 10);
34+
// Lorem i...
2935

3036
#### Limiting the number of words in a string:
3137

32-
echo Str::words($string, 10);
38+
echo Str::words("Lorem ipsum dolor sit amet", 3);
39+
// Lorem ipsum dolor...
3340

3441
<a name="random"></a>
3542
## Generating Random Strings
@@ -45,17 +52,17 @@ The **Str** class also provides three convenient methods for manipulating string
4552
<a name="singular-and-plural"></a>
4653
## Singular & Plural
4754

48-
The String class is capable of transforming your strings from singular to plural, and vice versa.
49-
5055
#### Getting the plural form of a word:
5156

5257
echo Str::plural('user');
58+
// users
5359

5460
#### Getting the singular form of a word:
5561

5662
echo Str::singular('users');
63+
// user
5764

58-
#### Getting the plural form if given value is greater than one:
65+
#### Getting the plural form if specified value is greater than one:
5966

6067
echo Str::plural('comment', count($comments));
6168

@@ -65,8 +72,10 @@ The String class is capable of transforming your strings from singular to plural
6572
#### Generating a URL friendly slug:
6673

6774
return Str::slug('My First Blog Post!');
75+
// my-first-blog-post
6876

6977
#### Generating a URL friendly slug using a given separator:
7078

7179
return Str::slug('My First Blog Post!', '_');
80+
// my_first_blog_post
7281

0 commit comments

Comments
 (0)