Reputation: 23
I have a 2 collection. I want to combine.
$a = collect([1,2,3]);
$b = collect(['a','b','c']);
I want that ;
$c = 1-a ;
How do I combine the two?
{{ Form::select('things', $c , NULL,NULL ['id' => 'myselect']) }}
Upvotes: 1
Views: 985
Reputation: 2866
First of all, you need to combine these collections.
$a = collect([1,2,3]);
$b = collect(['a','b','c']);
$combined = $a->combine($b);
Then use map()
method for manipulate your collection items
$united = $combined->map(function ($value,$key){
return $key."-".$value;
});
Upvotes: 2
Reputation: 2469
$a = collect([1,2,3]);
$b = collect(['a','b','c']);
$c = $a->combine($b);
$d = $c->map(function($item, $key){
return $item . '-' . $key;
});
Upvotes: 1