PHPackages                             bluzphp/collection - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bluzphp/collection

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bluzphp/collection
==================

Collection package

2.2.0(1y ago)0702↓50%1MITPHP &gt;=8.2

Since May 30Compare

[ Source](https://github.com/bluzphp/collection)[ Packagist](https://packagist.org/packages/bluzphp/collection)[ RSS](/packages/bluzphp-collection/feed)WikiDiscussions Synced 3d ago

READMEChangelog (7)Dependencies (1)Versions (9)Used By (1)

Collection Component
====================

[](#collection-component)

Achievements
------------

[](#achievements)

[![PHP >= 8.2+](https://camo.githubusercontent.com/ce30a0a42a5c06bf48c3d883444ae5fa0fdc071539e65e47a2a0c2a6100190f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f626c757a7068702f636f6c6c656374696f6e2e7376673f7374796c653d666c6174)](https://php.net/)

[![Latest Stable Version](https://camo.githubusercontent.com/61efe7c311aa7a54f790f47dfd9ad390d4d1011a90b5be535196d5f3f6e6a129/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c757a7068702f636f6c6c656374696f6e2e7376673f6c6162656c3d76657273696f6e267374796c653d666c6174)](https://packagist.org/packages/bluzphp/collection)

[![Build Status](https://camo.githubusercontent.com/5a9b9c3baa183f3239021016da7fadbac721bef121cb556d72c6c5b1f40b984d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f626c757a7068702f636f6c6c656374696f6e)](https://scrutinizer-ci.com/g/bluzphp/collection/build-status/master)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e55a86e0899693673354cb0b6899a3f16107c089b56e1c2b33ad8dbebfdc7dfb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f626c757a7068702f636f6c6c656374696f6e2e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/bluzphp/collection/)

[![Total Downloads](https://camo.githubusercontent.com/1f0c414fd4b20a2ce7452fbb1b29537c957a25617033724bbf770831b03c7d55/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626c757a7068702f636f6c6c656374696f6e2e7376673f7374796c653d666c6174)](https://packagist.org/packages/bluzphp/collection)

[![License](https://camo.githubusercontent.com/42f40ab19ba5fa01c186cf9d8818e618624fc5afb840126c73d72b2552d53eb5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626c757a7068702f636f6c6c656374696f6e2e7376673f7374796c653d666c6174)](https://packagist.org/packages/bluzphp/collection)

Usage
-----

[](#usage)

Example of an array:

```
$arr = [
    'a',
    'b' => 'boo',
    'c' => [
        'c1',
        'c2',
        'c3'
    ],
    'd' => [
        'd1' => ['d1.1', 'd1.2'],
        'd2' => ['d2.1', 'd2.2'],
        'd3' => ['d3.1', 'd3.2'],
    ],
    'e' => null,
    'f' => false
];
```

### Check the element by key(s)

[](#check-the-element-by-keys)

Usage:

```
Collection::has(array $array, ...$keys);
array_has($array, ...$keys);
```

Examples:

```
array_has($array, 0);         // true
array_has($array, 'b');       // true
array_has($array, 'c', 0);    // true
array_has($array, 'd', 'd1'); // true
array_has($array, 'e');       // true
array_has($array, 'f');       // true
array_has($array, 'g');       // false
```

Compare to `isset()`:

```
isset($array['e']); // false
```

### Get the element by key(s)

[](#get-the-element-by-keys)

Usage:

```
Collection::get(array $array, ...$keys);
array_get(array $array, ...$keys);
```

Examples:

```
array_get($array, 0);         // 'a'
array_get($array, 'b');       // 'boo'
array_get($array, 'c', 0);    // 'c1'
array_get($array, 'd', 'd1'); // ['d1.1', 'd1.2']
array_get($array, 'e');       // null
array_get($array, 'e', 'e');  // null
```

### Add the element to the array by key(s)

[](#add-the-element-to-the-array-by-keys)

Usage:

```
Collection::add(array &$array, $key, ...$values);
array_add(array &$array, $key, ...$values);
```

Examples:

```
array_add($array, 'c', 'c3');           // $array['c'][] = 'c3'
array_add($array, 'd', 'd1', 'd1.3');   // $array['d']['d1'][] = 'd1.3'
array_add($array, 'g', 'g1', 'g1.1');   // $array['g']['g1'][] = 'g1.1'

// but
array_add($array, 'b', 'b1');           // InvalidArgumentException - $array['b'] is not an array
```

### Set the element of the array by key(s)

[](#set-the-element-of-the-array-by-keys)

This method is similar to native way.

Usage:

```
Collection::set(array &$array, $key, ...$values);
array_set(array &$array, $key, ...$values);
```

Examples:

```
array_set($array, 'g', 'game over');       // $array['g'] = 'game over';
array_set($array, 'h', 'high way', 'e95'); // $array['h']['high way'] = 'e95';
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity77

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~321 days

Recently: every ~291 days

Total

7

Last Release

659d ago

Major Versions

1.0.2 → 2.0.02022-07-17

PHP version history (6 changes)1.0.0PHP &gt;=7.1

1.0.1PHP &gt;=7.2

1.0.2PHP &gt;=7.3

2.0.0PHP &gt;=8.0

2.1.0PHP &gt;=8.1

2.2.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2734017?v=4)[Bluz Framework](/maintainers/bluzphp)[@bluzphp](https://github.com/bluzphp)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bluzphp-collection/health.svg)

```
[![Health](https://phpackages.com/badges/bluzphp-collection/health.svg)](https://phpackages.com/packages/bluzphp-collection)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
