Showing 10 of 2,044 results.

Laravel Collection Public API: combine

combine($values) The combine method is used to combine the keys of the collection the method was called on with the values of another collection or array (supplied as an argument for $values ). This method is equivalent to using PHP's...

The as Modifier | A Beginners Guide to Antlers Arrays and Loops

Example 1.9 uses the as modifier to create a copy of our original array. We can use the as modifier on any array, which is useful whenever we want to control where our output items appear without explicitly creating temporary variables. Our...

Laravel Collection Public API: chunk

chunk($size, $preserveKeys = false) The chunk method is useful when working with large collections in that it allows developers to create smaller collections to work with. The chunk method defines two parameters: $size , which is used to control...

Laravel Collection Public API: zip

zip($items) The zip method is used to merge the values of the $items array with the values within the Collection at the corresponding index. The zip method produces results that are similar to Python's zip function, and developer's coming from a...

Laravel Collection Public API: sum

sum($callback = null) The sum is a simple method that returns the sum of all items in a collection. It also defines a $callback parameter which can be used to tell the sum method which values of the collection should be added together. If no items...