Laravel 8 combine() {#collection-method}

2021-07-19 09:33 更新

combine 方法將一個(gè)集合的值作為鍵,與另一個(gè)數(shù)組或集合的值進(jìn)行結(jié)合:

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

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

$combined->all();

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

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)