%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/public_html/vendor/cakephp/cakephp/src/Collection/ |
Upload File : |
[](https://packagist.org/packages/cakephp/collection)
[](LICENSE.txt)
# CakePHP Collection Library
The collection classes provide a set of tools to manipulate arrays or Traversable objects.
If you have ever used underscore.js, you have an idea of what you can expect from the collection classes.
## Usage
Collections can be created using an array or Traversable object. A simple use of a Collection would be:
```php
use Cake\Collection\Collection;
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
// Create a new collection containing elements
// with a value greater than one.
$overOne = $collection->filter(function ($value, $key, $iterator) {
return $value > 1;
});
```
The `Collection\CollectionTrait` allows you to integrate collection-like features into any Traversable object
you have in your application as well.
## Documentation
Please make sure you check the [official documentation](https://book.cakephp.org/3.0/en/core-libraries/collections.html)