Laravel 5.3 中文文档
['name' => 'iPhone 6S', 'brand' => 'Apple'], ], 'Samsung' => [ ['name' => 'Galaxy S7', 'brand' => 'Samsung'] ], ]); $products = $collection->flatten(1); $produc 'brand' => 'Apple'], ['name' => 'Galaxy S7', 'brand' => 'Samsung'], ] */ 在本例中,调用不提供深度的 flatten 方法也会对嵌套数组进行扁平化处理,返回结果 是 ['iPhone 6S', 'Apple', 'Galaxy S7', 'Samsung'] 。提供深度允许你严格设置被扁平化的数 组层级。 Watch', 'brand' => 'Apple', 'type' => 'watch '], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone '], ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watc h'], ]); $unique0 码力 | 691 页 | 9.37 MB | 1 年前3Laravel 5.1 中文文档
Watch', 'brand' => 'Apple', 'type' => 'wat ch'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'pho ne'], ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'w atch'], ]); 本文档由 [ ['name' => 'iPhone 6', 'brand' => 'Apple', 'type' => 'ph one'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'], ] */ 你还可以指定自己的回调用于判断数据项唯一性: $unique = 'brand' => 'Apple', 'type' => 'watch'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'], ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watch'], ] */0 码力 | 307 页 | 3.46 MB | 1 年前3Laravel 5.6 中文文档
['name' => 'iPhone 6S', 'brand' => 'Apple'], ], 'Samsung' => [ ['name' => 'Galaxy S7', 'brand' => 'Samsung'] ], ]); 本文档由 Laravel 学院提供 Laravel 学院致力于提供优质 Laravel 中文学 6S', 'brand' => 'Apple'], ['name' => 'Galaxy S7', 'brand' => 'Samsung'], ] */ 在本例中,调用不提供深度的 flatten 方法也会对嵌套数组进行扁平化处理,返回结果是 ['iPhone 6S', 'Apple', 'Galaxy S7', 'Samsung']。提供深度允许你严格设置被扁平化的数组层级。 Watch', 'brand' => 'Apple', 'type' => 'watch'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'], ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watch'], ]); $unique0 码力 | 377 页 | 14.56 MB | 1 年前3Laravel 5.2 中文文档
Watch', 'brand' => 'Apple', 'type' => 'wat ch'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'pho ne'], ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'w atch'], ]); $unique [ ['name' => 'iPhone 6', 'brand' => 'Apple', 'type' => 'ph one'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'], ] */ 你还可以指定自己的回调用于判断数据项唯一性: $unique = 'brand' => 'Apple', 'type' => 'watch'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'], ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watch'], ] */0 码力 | 377 页 | 4.56 MB | 1 年前3Laravel 6.0 中文文档
['name' => 'Galaxy S7', 'brand' => 'Samsung'] ], ]); $products = $collection->flatten(1); $products->values()->all(); /* [ ['name' => 'iPhone 6S', 'brand' => 'Apple'], ['name' => 'Galaxy S7', 'brand' 'brand' => 'Samsung'], ] */ 在本例中,调用不提供深度的 flatten 方法也会对嵌套数组进行扁 平化处理,返回结果是 ['iPhone 6S', 'Apple', 'Galaxy S7', 'Samsung']。提供深度允许你严格设置被扁平化的数组层级。 flip() flip 方法将集合的键值做交换: $collection = collect(['name' Watch', 'brand' => 'Apple', 'typ e' => 'watch'], ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'typ e' => 'phone'], ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 't ype' => 'watch'], ]); $unique0 码力 | 1442 页 | 14.66 MB | 1 年前3
共 5 条
- 1