PHPackages                             narrowspark/arr - 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. narrowspark/arr

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

narrowspark/arr
===============

A collection of utilities to manipulate arrays.

v2.1.1(9y ago)232.1k2[2 PRs](https://github.com/narrowspark/arr/pulls)1MITPHPPHP ^7.0

Since Jan 14Pushed 3y ago2 watchersCompare

[ Source](https://github.com/narrowspark/arr)[ Packagist](https://packagist.org/packages/narrowspark/arr)[ Docs](https://github.com/narrowspark/arr)[ RSS](/packages/narrowspark-arr/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (7)Dependencies (3)Versions (10)Used By (1)

A PHP collection of utilities to manipulate arrays. Compatible with, PHP 7 and Php 7.1.

[![Author](https://camo.githubusercontent.com/018ebedbe44f8f590bb7ca7fa60baf7dee5fad6ac186a0fa69dcc87eed4f76f0/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d40616e6f6c696c61622d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/anolilab)[![Latest Version on Packagist](https://camo.githubusercontent.com/312be4cc897355403867faeb98ffb026e40d08c3be5e1136aa8b26959f1ef861/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6172726f77737061726b2f6172722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/narrowspark/arr)[![Total Downloads](https://camo.githubusercontent.com/72d37179f8a81b2e65fe89ba20cdbfce9a3a349db9f962980cfb99c3914a99ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6172726f77737061726b2f6172722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/narrowspark/arr)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Master
------

[](#master)

[![Build Status](https://camo.githubusercontent.com/60af6764a8460f7972e6acbc62ab97784cf887ceb004aaee9be08e3a4fb92119/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e6172726f77737061726b2f6172722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/narrowspark/arr)[![Coverage Status](https://camo.githubusercontent.com/ac6f689938a73ee069b93b3b36360d047121214bf02c9cecd34af7cfaabff04c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6e6172726f77737061726b2f6172722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/narrowspark/arr/code-structure)[![Quality Score](https://camo.githubusercontent.com/1fbffe89bae245dba5b3e1b491586c47179a1842bca97a54c3d99ba7cce689c2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e6172726f77737061726b2f6172722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/narrowspark/arr)

Develop
-------

[](#develop)

[![Build Status](https://camo.githubusercontent.com/fad945dbd3d0ed558e857147564d6267dbcff4068ae820e9adf2143eadd3e184/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e6172726f77737061726b2f6172722f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/narrowspark/arr)[![Coverage Status](https://camo.githubusercontent.com/6e614c20480e60bd9f479ef00c22263c2a583c637fac64318b680fb41c2e1795/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6e6172726f77737061726b2f6172722f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/narrowspark/arr/code-structure)[![Quality Score](https://camo.githubusercontent.com/fc45764b44792e638525e441dc318bf5a484c18e46d4fced246437bee6d00ba3/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e6172726f77737061726b2f6172722f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/narrowspark/arr)

- [Installation](#installation)
- [Arr](#arr)
    - [Access methods](#access)
        - [set](#set)
        - [get](#get)
        - [add](#add)
        - [has](#has)
        - [put](#put)
        - [exists](#exists)
        - [update](#update)
        - [forget](#forget)
    - [Enumerator](#enumerator)
        - [random](#random)
        - [only](only)
        - [split](#split)
        - [isAssoc](#isAssoc)
        - [isIndexed](#isIndexed)
    - [Transform](#transform)
        - [pop](#pop)
        - [swap](#swap)
        - [every](#every)
        - [combine](#combine)
        - [collapse](#collapse)
        - [divide](#divide)
        - [stripEmpty](#stripEmpty)
        - [unique](#unique)
        - [without](#without)
        - [reindex](#reindex)
        - [merger](#merge)
        - [extend](#extend)
        - [asHierarchy](#asHierarchy)
        - [groupBy](#groupBy)
        - [dot](#dot)
        - [flatten](#flatten)
        - [expand](#expand)
        - [reset](#reset)
        - [extendDistinct](#extendDistinct)
        - [sortRecursive](#sortRecursive)
        - [zip](#zip)
    - [Traverse](#traverse)
        - [map](#map)
        - [filter](#filter)
        - [all](#all)
        - [reject](#reject)
        - [where](#where)
        - [first](#first)
        - [last](#last)

Why?
----

[](#why)

Installation
------------

[](#installation)

Via Composer

```
$ composer require narrowspark/arr
```

or

```
"require": {
    "narrowspark/arr": "~2.0"
}
```

Arr
---

[](#arr)

All methods listed under "Arr".

```
use Narrowspark\Arr\Arr;

// Returns a new array with the added key and value;
// ['foo' => bar, 'arr' => 'narrowsaprk']
Arr::set(['foo' => bar], 'arr', 'narrowspark');
```

#### set

[](#set)

Set an array item to a given value using "dot" notation. If no key is given to the method, the entire array will be replaced.

```
    $arr = Arr::set(['foo' => 'bar'], 'arr', 'narrowspark'); // ['foo' => 'bar', 'arr' => 'narrowspark']
```

#### get

[](#get)

Get an item from an array using "dot" notation. If key dont exist, you get a default value back.

```
    $arr = Arr::get(['foo' => 'bar'], 'foo', 'narrowspark'); // bar
```

#### add

[](#add)

Add an element to the array at a specific location using the "dot" notation.

```
    $arr = Arr::add(['foo' => 'bar'], 'foo', 'narrowspark'); // ['foo' => ['bar', 'narrowspark']]
```

#### has

[](#has)

Check if an item exists in an array using "dot" notation.

```
    $arr = Arr::has(['foo' => 'bar'], 'foo'); // true
```

#### update

[](#update)

Updates data at the given path.

```
    $increment = function ($value) {
        return $value + 1;
    };

    $arr = Arr::update(['foo' => 1], $increment); // ['foo' => 2]
```

#### forget

[](#forget)

Remove one or many array items from a given array using "dot" notation.

```
    $arr = ['foo' => 'bar']

    Arr::forget($arr, 'foo');

    $arr; // []
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

From the project directory, tests can be ran using phpunit

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Daniel Bannert](https://github.com/prisis)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~41 days

Recently: every ~25 days

Total

7

Last Release

3530d ago

Major Versions

v1.2.0 → v2.0.02016-09-16

PHP version history (3 changes)v1.0PHP &gt;=5.6.4

v1.1.0PHP ^5.6 || ^7.0

v2.0.0PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca62e19a98f43cce88fa6733762bebbe26f4e7ee0b3d8defdadfd0b7082f77a0?d=identicon)[dani33](/maintainers/dani33)

---

Top Contributors

[![prisis](https://avatars.githubusercontent.com/u/2716058?v=4)](https://github.com/prisis "prisis (86 commits)")

---

Tags

arrayarray-helperarray-manipulationsarray-methodsdot-notationmanipulate-arraysmulti-arrayphp7arraymanipulate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/narrowspark-arr/health.svg)

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

###  Alternatives

[doctrine/collections

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

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar to jQuery and Laravel Collections

4.2k412.9k11](/packages/aimeos-map)

PHPackages © 2026

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