Showing 7 of 1,216 result(s)
put($key, $value) The put method is used to add a new item to the collection with a given $key and $value . The put method modifies the original Collection instance and returns a reference to it. The following code example will highlight the usage...
random($amount = 1) The random method will retrieve a random $amount of items from the collection. By default, the random method will return only one item, however a different $amount can be passed in to change the number of items returned. If the...
reduce(callable $callback, $initial = null) 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 item. The $callback function should define two...
reject($callback) The reject method used to create a new Collection instance containing all the items in the collection that do not pass a given truth test. The reject method only defines one parameter: $callback . The $callback function should...
reverse The reverse method is used to reverse the order of items in a collection. The reverse method returns a new Collection instance. The reverse method does not preserve numerical keys but will preserve non-numerical keys. The following code...
search($value, $strict = false) The search method is used to search the collection for a given $value . If the given $value is found, the value's corresponding key is returned. If the $value is not found in the collection, the search method will...
shift The shift method is used to remove the first item from the collection and return its value. The shift method modifies the collection instance. The following code example shows how to use the shift method: After the above code has executed,...