Laravel 8 combine() {#collection-method}

2021-07-19 09:33 更新

combine 方法將一個集合的值作為鍵,與另一個數組或集合的值進行結合:

$collection = collect(['name', 'age']);

$combined = $collection->combine(['George', 29]);

$combined->all();

// ['name' => 'George', 'age' => 29]
以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號