Showing 7 of 1,216 result(s)
shuffle 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...
slice($offset, $length = null, $preserveKeys = false) The slice method is used to return a slice, or portion of the collection starting at the given $offset . The $offset tells the slice method where to begin when creating the collection. For...
sort(callable $callback = null) The sort method is used to sort the collection. If no $callback is provided, the collection will be sorted using a case-insensitive "natural order" algorithm. An optional $callback can be supplied to customize the...
sortBy($callback, $options = SORT_REGULAR, $descending = false) The sortBy method is useful and versatile way to sort collections by some key, or by some value returned by a $callback . The $callback can either be a function that defines two...
sortByDesc($callback, $options = SORT_REGULAR) The sortByDesc method operates exactly the same as the sortBy method. The only differences is that the sortByDesc method does not define a $descending parameter. The sortByDesc method internally makes...
splice($offset, $length = null, $replacement = []) The splice method is a versatile 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...
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...