Skip to content

Commit 53b9eea

Browse files
committed
IHF: multiarray_set readme added.
1 parent 13172eb commit 53b9eea

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Provides Laravel-specific and pure PHP helper functions.
3434
3535
- [Array](#array)
3636
- [array_except_value](#array_except_value)
37+
- [multiarray_set](#multiarray_set)
3738
- [multiarray_sort_by](#multiarray_sort_by)
3839
3940
- [Artisan](#artisan)
@@ -95,6 +96,26 @@ $array = array_except_value($array, ['bar', 'baz']);
9596
// ['foo']
9697
```
9798
99+
#### `multiarray_set()`
100+
101+
Sets a value for each item of multidimensional array using "dot" notation:
102+
103+
```php
104+
$array = [
105+
['name' => 'Mercedes-Benz', 'details' => ['type' => 'SUV']],
106+
['name' => 'BMW', 'details' => ['type' => 'SUV']],
107+
['name' => 'Porsche', 'details' => ['type' => 'SUV']],
108+
];
109+
110+
multiarray_set($array, 'details.country', 'Germany');
111+
112+
// [
113+
// ['name' => 'Mercedes-Benz', 'details' => ['type' => 'SUV', 'country' => 'Germany']],
114+
// ['name' => 'BMW', 'details' => ['type' => 'SUV', 'country' => 'Germany']],
115+
// ['name' => 'Porsche', 'details' => ['type' => 'SUV', 'country' => 'Germany']],
116+
// ]
117+
```
118+
98119
#### `multiarray_sort_by()`
99120
100121
Sorts multidimensional array by multiple fields:

0 commit comments

Comments
 (0)