Showing 7 of 1,216 result(s)
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 only have one...
The toArray method is similar to the all method in that it will return the underlying array that the collection instance is using. The difference, however, is that the toArray method will convert any object instance it can into arrays (namely any...
The mapInto method is similar to the transform method in that allows you to quickly convert, or project, the contents of the collection to a new type. However, instead of building up the resulting type instance yourself, the mapInto method creates...
The jsonSerialize method will convert the contents of the collection into something that be serialized using PHP's json_encode function. This method will iterate the collection's internal array and will evaluate each element in accordance with the...
When a Collection instance is cast into a string, its JSON representation is returned as the result. Internally this is accomplished by returning the results of the collection's toJson method. After the above code has executed, the $stringValue...
The toJson method will return a JSON encoded version of the data stored within the collection instance. It internally does this by returning a call to PHP's json_encode function, passing in any $options that were supplied. Like the json_encode...
The collapse method combines all the first-level items of a collection into a new, single collection. The returned value of the collapse method is an instance of the Collection class.public function collapse();We will create a simple collection to...