laravel merge two arrays helper

Solutions on MaxInterview for laravel merge two arrays helper by the best coders in the world

showing results for - "laravel merge two arrays helper"
Mirko
10 Nov 2016
1Arr::add()
2The Arr::add method adds a given key / value pair to an array if the given key doesn't already exist in the array or is set to null:
3
4use Illuminate\Support\Arr;
5
6$array = Arr::add(['name' => 'Desk'], 'price', 100);
7
8// ['name' => 'Desk', 'price' => 100]
9
10$array = Arr::add(['name' => 'Desk', 'price' => null], 'price', 100);
11
12// ['name' => 'Desk', 'price' => 100]