PHPackages                             steein/collections - 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. steein/collections

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

steein/collections
==================

Steein Collections - Collection library for working with data. Edit

1.1.5(9y ago)1421MITPHPPHP ^5.6.30 | ^7.0

Since Apr 29Pushed 9y agoCompare

[ Source](https://github.com/SteeinRu/Collections)[ Packagist](https://packagist.org/packages/steein/collections)[ Docs](http://www.steein.ru)[ RSS](/packages/steein-collections/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (1)

Steein Collections
==================

[](#steein-collections)

Collection library for working with data.

Using Collection
----------------

[](#using-collection)

```
use Steein\Common\Collections\Collection;

//Generated default array
$array = [
    'name'      =>  'Shamsudin',
    'project'   =>  'Steein',
    'text'      =>  'default text',

    'Cars'  =>  [
        'car_audi' =>  'Audi',
        'car_bwm'  =>  'Bmw'
    ]
];

//Default
$collection = new Collection($array);

//Or Static implementation
$collection = Collection::instance($array);
```

### Available methods and implementation methods

[](#available-methods-and-implementation-methods)

In this documentation we will describe the most necessary methods, and all the rest, and you can see a lot of them in the code, everything is described there

---

The magic method for creating and retrieving a new item for the collection

```
$collection->new_array = 'value';
```

**toArray()**

Getting the collections of elements in the Array format.

```
$collection->toArray()
```

**toJson()**

Getting the collections of elements in the Json format.

```
$collection->toJson();
```

**toXml()**

Getting the collections of elements in the Json format.

```
$collection->toXml();
```

**set()**

New item for collection

```
$collection->set('key', 'value');
```

**get()**

Get the item from the collection by key.

```
$collection->get('key');
```

**slice()**

Create the main array of the collection.

```
$collection->slice(1);
```

**nth()**

Create a new collection of each n-th attribute.

```
$collection->nth(2);
```

**union()**

Union of collections with these elements.

```
$new_collection = Collection::instance([0 => ['a'], 1 => ['b'], 2 => ['c']]);
$new_collection->union([3 => ['b'], 2 => ['c']]);
```

**combine()**

Create a collection using this collection for keys, and the other for its values.

```
$new_collection = Collection::instance(['firstname','lastname','age']);
$new_collection->combine(['Shamsudin','Serderov', 22]);
```

**merge()**

Combine the collection with these elements.

```
$new_collection = Collection::instance(['id_goods' => 100,'price' => 10000, 'instock' => 0]);
$new_collection->merge(['price' => 9550, 'count' => 1]);
```

**isEmpty()**

Determine whether the collection is empty or not.

```
$collection->isEmpty();
```

**isNotEmpty()**

Determine if the collection is empty.

```
$collection->isNotEmpty();
```

**has()**

Determine if an element exists in the collection by key.

```
$collection->has('project');
```

**forget()**

Remove an item from the collection by key.

```
$collection->forget('name');
```

**archive()**

Archive the collection with one or more arrays.

```
$new_collection = Collection::instance(['test', 'test1']);
$new_collection->archive([50, 22]);
```

**clear()**

Clearing Attributes in the Collection

```
$collection->clear();
```

**count()**

Count the number of items in the collection.

```
$collection->count()
```

**flip()**

We turn the elements into collections.

```
$flip = $collection->flip();
$flip->all();
```

**values()**

Get values from items in the collection

```
$collection->values();
```

**keys()**

Get the keys to the attributes of the collection.

```
$collection->keys();
```

**indexOf()**

We search for a specific value in the collection

```
$collection->indexOf('Shamsudin');
```

**all()**

Get all attributes

```
$collection->all();
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3303d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/25b3e90822a52d3d64e79e88c911e20e16f8d08ceb759f52ad75884a85a8b302?d=identicon)[Steein](/maintainers/Steein)

---

Tags

arraycollectioncollectionscountjson-formatlibrarynthphpphp7steein-collectionsunionarrayiteratorcollections

### Embed Badge

![Health badge](/badges/steein-collections/health.svg)

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[ginq/ginq

LINQ to Object inspired DSL for PHP

192257.5k3](/packages/ginq-ginq)[malarzm/collections

Various implementations of Doctrine's Collection interface

2368.1k](/packages/malarzm-collections)[rotexsoft/versatile-collections

A collection package that can be extended to implement things such as a Dependency Injection Container, RecordSet objects for housing database records, a bag of http cookies, or technically any collection of items that can be looped over and whose items can each be accessed using array-access syntax or object property syntax.

186.0k1](/packages/rotexsoft-versatile-collections)[vistik/typed-collections

A simple way to create typed collections in PHP - build on Illuminate\\Support\\Collection

1128.2k5](/packages/vistik-typed-collections)

PHPackages © 2026

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