Showing 7 of 587 result(s)
The whereStrict method is similar to the where method, but it will always use strict comparisons when determining the results to return.The $sampleCollection collection instance will be used in the following examples: If you noticed, the first...
The filter method applies a filter to the collection. An optional $callback can be supplied to the filter method. If no $callback is supplied to the filter method, any value in the collection that evaluates to false will be removed from the final...
The where method allows developers to filter a collection given a key value pair. It filters the collection's items by checking that the given $key has some value equal to the provided $value . An argument can be supplied for the $operator...
The count method will return the number of elements contained within the collection's inner array; it is synonymous with PHP's count function.public function count();The count method is a straightforward method and simply returns the total number...
The groupBy method is used to group a collection based on a given value, represented by the $groupBy parameter. An argument passed to $groupBy can be a simple string, representing the value that the collection should be grouped by, or a callback...
By default, the groupBy method will not preserve the keys in the underlying collection when grouping items. The following code sample shows how the groupBy method groups by default, and the output: The $grouped variable would now have a value...
The chunk method can be used to achieve similar results. The following code sample will use the same collection from the previous example, and chunk it into smaller collections each containing two items. The $pages variable is also an instance of...