Re: Collection::reduce versus doing a foreach

2015-09-22 Thread José Lorenzo
Maybe this is what you are looking for: collection($items) // I only care about elements having the id = a or id = b ->filter(function ($value, $key) use ($array) { return isset($array[$value['id']]); // If the key is in the array, the it should be kept in the collection })

Re: Collection::reduce versus doing a foreach

2015-09-20 Thread Walter Vos
Sorry to bump this, but I'm really hoping someone can help me understand this. -Walter On Monday, September 14, 2015 at 10:08:55 AM UTC+2, Walter Vos wrote: > > Hi! > > I'm having trouble wrapping my head around Collection::reduce. Actually, > it feels like I understand how it's supposed to wor

Collection::reduce versus doing a foreach

2015-09-14 Thread Walter Vos
Hi! I'm having trouble wrapping my head around Collection::reduce. Actually, it feels like I understand how it's supposed to work, but in reality it seems to work differently. I have a collection of entities, from which I'm trying to concat a number of string, based on another array (could prob