阅读(3914) (22)

Laravel 8 Arr::only() {#collection-method}

2021-07-02 16:49:01 更新

Arr::only 函数只返回给定数组中指定的键值对:

use Illuminate\Support\Arr;

$array = ['name' => 'Desk', 'price' => 100, 'orders' => 10];

$slice = Arr::only($array, ['name', 'price']);

// ['name' => 'Desk', 'price' => 100]