Showing 7 of 1,216 result(s)
The shuffle method is used to rearrange the items of the array in a random distribution. The shuffle method will return a new collection and will not modify the original collection instance.The following code example shows the usage of the shuffle...
In computing, a dictionary is a data structure where there exists a relationship between a single key and a value, or a list multiple values; examples of these are associative arrays and maps (both of which are easily implemented with PHP arrays)....
The mapToGroups method is similar to the mapToDictionary method, in that the mapToGroups method allows you take a collection of data and reduce it such that the final result is a collection of key/value pairs. The resulting value for each key may...
The reduce method is to reduce a collection into only one item. It does this by iterating over the collection and applying the $callback function on each element. The $callback function should define two parameters: $carry and $item . The $carry...
The mapWithKeys is similar to the mapToDictionary and mapToGroups methods in that it accepts a $callback function that defines an association between the returned key and value. The mapWithKeys method does not change the original collection; it...
The flatten method will return a new Collection instance representing a flattened version of the original collection's items. The flatten method internally makes use of the "Illuminate\Support\Arr::flatten($array)" helper method. The flatten...
The splice method is a useful method; it is often used to remove a portion of a collection and return the removed section. It defines three parameters: $offset , $length and $replacement . The $offset tells the splice method where to begin when...