Add Array in Laravel

Submitted by Xubayer - 7 years ago

The array_add function adds a given key / value pair to the array if the given key doesn't already exist in the array.

$array = ['foo' => 'bar'];

$array = array_add($array, 'key', 'value');