Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b346ab0

Browse files
milwad-devtaylorotwell
andauthored
[12.x] Add Arr::push to helpers (#10731)
* Update helpers.md * Update helpers.md * Update helpers.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 73749bb commit b346ab0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎helpers.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
7373
[Arr::prepend](#method-array-prepend)
7474
[Arr::prependKeysWith](#method-array-prependkeyswith)
7575
[Arr::pull](#method-array-pull)
76+
[Arr::push](#method-array-push)
7677
[Arr::query](#method-array-query)
7778
[Arr::random](#method-array-random)
7879
[Arr::reject](#method-array-reject)
@@ -959,6 +960,21 @@ use Illuminate\Support\Arr;
959960
$value = Arr::pull($array, $key, $default);
960961
```
961962

963+
<a name="method-array-push"></a>
964+
#### `Arr::push()` {.collection-method}
965+
966+
The `Arr::push` method pushes an item into an array using "dot" notation. If an array does not exist at the given key, it will be created:
967+
968+
```php
969+
use Illuminate\Support\Arr;
970+
971+
$array = [];
972+
973+
Arr::push($array, 'office.furniture', 'Desk');
974+
975+
// $array: ['office' => ['furniture' => 'Desk']]
976+
```
977+
962978
<a name="method-array-query"></a>
963979
#### `Arr::query()` {.collection-method}
964980

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /