Skip to content

Commit

Permalink
IHF: multiarray_set readme added.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ivanov committed Mar 17, 2017
1 parent 13172eb commit 53b9eea
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Provides Laravel-specific and pure PHP helper functions.
- [Array](#array)
- [array_except_value](#array_except_value)
- [multiarray_set](#multiarray_set)
- [multiarray_sort_by](#multiarray_sort_by)
- [Artisan](#artisan)
Expand Down Expand Up @@ -95,6 +96,26 @@ $array = array_except_value($array, ['bar', 'baz']);
// ['foo']
```
#### `multiarray_set()`
Sets a value for each item of multidimensional array using "dot" notation:
```php
$array = [
['name' => 'Mercedes-Benz', 'details' => ['type' => 'SUV']],
['name' => 'BMW', 'details' => ['type' => 'SUV']],
['name' => 'Porsche', 'details' => ['type' => 'SUV']],
];
multiarray_set($array, 'details.country', 'Germany');
// [
// ['name' => 'Mercedes-Benz', 'details' => ['type' => 'SUV', 'country' => 'Germany']],
// ['name' => 'BMW', 'details' => ['type' => 'SUV', 'country' => 'Germany']],
// ['name' => 'Porsche', 'details' => ['type' => 'SUV', 'country' => 'Germany']],
// ]
```
#### `multiarray_sort_by()`
Sorts multidimensional array by multiple fields:
Expand Down

0 comments on commit 53b9eea

Please sign in to comment.