Skip to content

Commit 4944720

Browse files
authored
Merge pull request laravel#5057 from chapeupreto/patch-6
[5.8] add documentation to `join` method on collection
2 parents 22b007b + 1c0e415 commit 4944720

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

collections.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ For the remainder of this documentation, we'll discuss each method available on
105105
[intersectByKeys](#method-intersectbykeys)
106106
[isEmpty](#method-isempty)
107107
[isNotEmpty](#method-isnotempty)
108+
[join](#method-join)
108109
[keyBy](#method-keyby)
109110
[keys](#method-keys)
110111
[last](#method-last)
@@ -937,6 +938,17 @@ The `isNotEmpty` method returns `true` if the collection is not empty; otherwise
937938

938939
// false
939940

941+
<a name="method-join"></a>
942+
#### `join()` {#collection-method}
943+
944+
The `join` method joins the collection's values with a string:
945+
946+
collect(['a', 'b', 'c'])->join(', '); // 'a, b, c'
947+
collect(['a', 'b', 'c'])->join(', ', ', and '); // 'a, b, and c'
948+
collect(['a', 'b'])->join(', ', ' and '); // 'a and b'
949+
collect(['a'])->join(', ', ' and '); // 'a'
950+
collect([])->join(', ', ' and '); // ''
951+
940952
<a name="method-keyby"></a>
941953
#### `keyBy()` {#collection-method}
942954

0 commit comments

Comments
 (0)