Answers for "laravel collection flatten"

PHP
0

laravel collection flatten

$collection = collect(['name' => 'taylor', 'languages' => ['php', 'javascript']]);

$flattened = $collection->flatten();

$flattened->all();

// ['taylor', 'php', 'javascript'];
Posted by: Guest on July-24-2021
1

laravel collection methods

$collection = collect([1,2,3,4]);

$collection->each(function($item){
    return $item*$item;
});

// [1,4,9,16]
Posted by: Guest on September-06-2020

Browse Popular Code Answers by Language