📅  最后修改于: 2022-03-11 14:54:26.103000             🧑  作者: Mango
Arr::add()
The 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:
use Illuminate\Support\Arr;
$array = Arr::add(['name' => 'Desk'], 'price', 100);
// ['name' => 'Desk', 'price' => 100]
$array = Arr::add(['name' => 'Desk', 'price' => null], 'price', 100);
// ['name' => 'Desk', 'price' => 100]