📜  laravel 集合 flatMap - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:47.200000             🧑  作者: Mango

代码示例1
$collection = collect([
    ['name' => 'Sally'],
    ['school' => 'Arkansas'],
    ['age' => 28]
]);

$flattened = $collection->flatMap(function ($values) {
    return array_map('strtoupper', $values);
});

$flattened->all();

// ['name' => 'SALLY', 'school' => 'ARKANSAS', 'age' => '28'];