Skip to content

Commit

Permalink
Add readme section for array set
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrieghe committed Jul 17, 2018
1 parent fd7761b commit c2ce0a4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,25 @@ Arr::has($data, 'xyz');
```

Note that `Arr::has()` can be replaced with `array_has()` if you prefer a functional approach.

#### Array Set

This helper sets a certain key in an array to a certain value.
Dot notation can be used to create a deeply nested key.

```
$data = [];
Arr::set($data, 'foo.bar', 'baz');
```

`$data` now contains:
```
[
'foo' => [
'bar' => 'baz',
],
];
```

Note that `Arr::set()` can be replaced with `array_set()` if you prefer a functional approach.

0 comments on commit c2ce0a4

Please sign in to comment.