Skip to content

Commit c2ce0a4

Browse files
committed
Add readme section for array set
1 parent fd7761b commit c2ce0a4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,25 @@ Arr::has($data, 'xyz');
8989
```
9090

9191
Note that `Arr::has()` can be replaced with `array_has()` if you prefer a functional approach.
92+
93+
#### Array Set
94+
95+
This helper sets a certain key in an array to a certain value.
96+
Dot notation can be used to create a deeply nested key.
97+
98+
```
99+
$data = [];
100+
Arr::set($data, 'foo.bar', 'baz');
101+
```
102+
103+
`$data` now contains:
104+
```
105+
[
106+
'foo' => [
107+
'bar' => 'baz',
108+
],
109+
];
110+
```
111+
112+
Note that `Arr::set()` can be replaced with `array_set()` if you prefer a functional approach.
113+

0 commit comments

Comments
 (0)