PHPackages                             pisc/arrr - 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. pisc/arrr

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

pisc/arrr
=========

Array class for PHP

0.0.13(9y ago)31351MITPHPPHP &gt;=5.4

Since Apr 17Pushed 9y ago2 watchersCompare

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

READMEChangelogDependencies (2)Versions (9)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/e76c3c084cd53b8c400abd3e5de20d856a519617e7fb0ab4862d8e0749eb182f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706973632f617272722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pisc/arrr)[![Build Status](https://camo.githubusercontent.com/cefb9812986ceb3bce7953da581abf7b7a6c5c49d2d677dcb07085c5f6aee001/68747470733a2f2f7472617669732d63692e6f72672f5069657465725363686566666572732f617272722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PieterScheffers/arrr)

arrr ✅
======

[](#arrr-)

Array class for PHP

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

[](#installation)

```
$ composer require pisc/arrr
```

Instantiation:
--------------

[](#instantiation)

```
// shorthand function (global function)
$array = ar([ 'someKey' => 'someValue' ]);

// constructor
$array = new Arrr([ 'someKey' => 'someValue' ]);

$array = new Ar([ 'someKey' => 'someValue' ]); // returns Ar instance
$array->mapIt(function($item) {
	return $item . "_suffix";
}); // returns Arrr instance

// factory
$array = Arrr::ar([ 'someKey' => 'someValue' ]);
$array = Arrr::instance([ 'someKey' => 'someValue' ]);
$array = Ar::ar([ 'someKey' => 'someValue' ]);
$array = Ar::instance([ 'someKey' => 'someValue' ]);
```

How to use:
-----------

[](#how-to-use)

```
use pisc\arrr\arrr;

$array = ar([ 'someKey' => 'someValue' ]);
```

```
$flat = Ar::flatten([ 'cow', [ 'bear', ['bunny', 'santa' ], 'rabbit' ]]);
```

Most methods are callable as:

- Static method with the first parameter the array - Ar::map($array, function($item) { return $item; })
- Instance method which returns a new instance of Arrr - $Arrr-&gt;map(function($item) { return $item; })
- Instance method which works on the current instance - $Arrr-&gt;mapIt(function($item) { return $item; })

Convention
----------

[](#convention)

All methods ending on 'It' modify the array itself and return itself, so you can do something like:

```
$places = ar([
	'Amsterdam',
	'Berlin',
	'Paris',
	'Vienna',
	'Rome',
	'Madrid'
]);

$places->filterIt(function($place) {
	return in_array($place[0], [ 'A', 'V', 'R' ]);
});

$places->mapIt(function($place) {
	return "To destination {$place}";
})

echo $places->toJson();

// returns
'[ "To destination Amsterdam", "To destination Vienna", "To destination Rome" ]'
```

Run tests
---------

[](#run-tests)

```
# When installed globally
$ phpunit

# When installed locally
$ ./vendor/bin/phpunit
```

Methods
-------

[](#methods)

### sortBy (sortByIt)

[](#sortby-sortbyit)

Sort an array by multiple keys or result of a closure When a compare function result in 0, it will test the next key or closure

accepts:

- $sortByKeys ((array) string / closure )
- $methods ((array) string / callable )

```
$array = ar([
	(object)[ 'id' => 1, 'name' => 'Jack', 'length' => 180 ],
	(object)[ 'id' => 2, 'name' => 'Jack', 'length' => 150 ],
	(object)[ 'id' => 3, 'name' => 'Ben', 'length' => 180 ],
	(object)[ 'id' => 4, 'name' => 'Ben', 'length' => 150 ],
	(object)[ 'id' => 5, 'name' => 'Vince', 'length' => 180 ],
	(object)[ 'id' => 6, 'name' => 'Vince', 'length' => 150 ],
]);

$sortedArray = $array->sortBy([ 'length', 'name' ], [ 'Sort::byDefault', 'strcmp' ]);

// result
[
	(object)[ 'id' => 4, 'name' => 'Ben', 'length' => 150 ],
	(object)[ 'id' => 2, 'name' => 'Jack', 'length' => 150 ],
	(object)[ 'id' => 6, 'name' => 'Vince', 'length' => 150 ],
	(object)[ 'id' => 3, 'name' => 'Ben', 'length' => 180 ],
	(object)[ 'id' => 1, 'name' => 'Jack', 'length' => 180 ],
	(object)[ 'id' => 5, 'name' => 'Vince', 'length' => 180 ],

]
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Recently: every ~10 days

Total

8

Last Release

3469d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d2fed0961c00c0f7f579df5fdd0a7acb90568ce214a473c2001e73a975a884b?d=identicon)[pisc](/maintainers/pisc)

---

Top Contributors

[![PieterScheffers](https://avatars.githubusercontent.com/u/5553195?v=4)](https://github.com/PieterScheffers "PieterScheffers (26 commits)")

---

Tags

arrayphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pisc-arrr/health.svg)

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

###  Alternatives

[benpickles/peity

Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini `&lt;svg&gt;` pie, donut, line or bar chart.

4.2k2.8k](/packages/benpickles-peity)[2amigos/yii2-grid-view-library

GridView Widget Extensions for Yii2.

56147.2k12](/packages/2amigos-yii2-grid-view-library)[zhuravljov/yii2-datetime-widgets

Datetime widgets for Yii2.

21118.6k3](/packages/zhuravljov-yii2-datetime-widgets)[smajti1/laravel-wizard

Wizard component for laravel.

409.2k](/packages/smajti1-laravel-wizard)[tivie/command

An utility library that harmonizes OS differences and executes external programs in a safer way

1455.3k1](/packages/tivie-command)[wedevelopnl/silverstripe-elemental-grid

Elemental grid module

1014.1k2](/packages/wedevelopnl-silverstripe-elemental-grid)

PHPackages © 2026

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