PHPackages                             transprime-research/arrayed - 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. transprime-research/arrayed

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

transprime-research/arrayed
===========================

PHP Array(ed) in object oriented way wrapping PHP arrays in a consistent manner.

2.3.1(2y ago)22242↓100%1[1 issues](https://github.com/transprime-research/arrayed/issues)1MITPHPPHP &gt;=7.4

Since May 1Pushed 2y ago3 watchersCompare

[ Source](https://github.com/transprime-research/arrayed)[ Packagist](https://packagist.org/packages/transprime-research/arrayed)[ Docs](https://transprime-research.github.io/arrayed/)[ RSS](/packages/transprime-research-arrayed/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (19)Used By (1)

[![](https://github.com/transprime-research/assets/raw/master/arrayed/twitter_header_photo_2.png)](https://github.com/transprime-research/assets/blob/master/arrayed/twitter_header_photo_2.png)

[ ![Build Status](https://camo.githubusercontent.com/0e0e6b4535f322bff06467803dbc935c139d59243b607c6d861b352f17b2475d/68747470733a2f2f7472617669732d63692e6f72672f7472616e737072696d652d72657365617263682f617272617965642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/transprime-research/arrayed)[ ![Latest Stable Version](https://camo.githubusercontent.com/dd90eb475fabfdfed5463fed7daf94bb814a3cf88e53dfaa33d65c13b94518f1/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f617272617965642f762f737461626c65)](https://packagist.org/packages/transprime-research/arrayed)[ ![Total Downloads](https://camo.githubusercontent.com/eb1cae0ee0f4f7e9ceb23682659a9b429c3a170699ae4a1c38436bfef1555565/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f617272617965642f646f776e6c6f616473)](https://packagist.org/packages/transprime-research/arrayed)[ ![Latest Unstable Version](https://camo.githubusercontent.com/570a442d3e14c69c7e2f4ee9d5dd373babc506fac014a06c220184c7aa8ec679/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f617272617965642f762f756e737461626c65)](https://packagist.org/packages/transprime-research/arrayed)[ ![Latest Monthly Downloads](https://camo.githubusercontent.com/be15baaeea3bd3dc0caae7043c83a0ed3119182f5a136fc75fab0650499c83ad/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f617272617965642f642f6d6f6e74686c79)](https://packagist.org/packages/transprime-research/arrayed) [ ![License](https://camo.githubusercontent.com/8b4ee537b46cd5aee04c4bd792a7c5808ca8d60e6abd0ba04cde30fa08ec01d9/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f617272617965642f6c6963656e7365)](https://packagist.org/packages/transprime-research/arrayed)

About Arrayed
-------------

[](#about-arrayed)

Simple PHP Array(ed) in object oriented way wrapping [PHP Arrays](https://www.php.net/manual/en/ref.array.php) in a consistent manner.

> No advanced stuff, just wrap PHP array\_\* functions and a little more. Do it Like a PRO 🆗

> Looking for PHP Array on Steroid? See:

Quick Usage
-----------

[](#quick-usage)

```
arrayed(1, 2, 'ninja')
    ->filter(fn($val) => is_int($val)) // [1,2]
    ->map(fn($val) => $val + 1) // [2, 3]
    ->flip() // [0, 1]
    ->values() // [0, 1]
    ->sum(); // 1
```

Instead of:

```
$result = array_filter([1, 2, 'ninja'], fn($val) => is_int($val));
$result = array_map(fn($val) => $val + 1, $result);
$result = array_flip($result);
$result = array_values($result);
$result = array_sum($result);
```

> PS: You can still use the old `function() { return v; }`, `fn()` is the new short arrow function in PHP 7.4+ See:

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

[](#installation)

```
composer require transprime-research/arrayed
```

Requirement
-----------

[](#requirement)

Minimum Requirement

- PHP 7.2 +
- Composer
- For using `collect()` method, requires `illuminate\support` &gt;= 5.5

> Additionally on Laravel App, if `arrayed.php`'s config file doesn't get added automatically then run `php artisan vendor:publish --tag=arrayed` after installation.

Other Usages
------------

[](#other-usages)

Arrayed can be instantiated in 3 ways:

```
use Transprime\Arrayed\Arrayed;

// Nifty
arrayed(1, 2)->count();

// Easier
Arrayed::on(1, 2)->count();

// Normal with (new instance)
(new Arrayed(1,2))->count();
```

Initial values can be passed in two ways:

```
//Non associative
arrayed(1, 2);

//OR
arrayed([1, 2]);

// For associative array, only this way
arrayed(['a' => 1, 'b' => 2]);
```

#### With Laravel &amp; Laravel Collection

[](#with-laravel--laravel-collection)

Laravel Collections

New: `collect()` method 🎉

```
arrayed(1,2)->collect(); // instance of Illuminate/Support/Collection
arrayed(1,2)->collect(3, 4); //merged with first one to give [1, 2, 3, 4]
```

> In the future, changing the default Collection class will possible by editing `config/arrayed.php`'s collection\_class value

Others:

```
collect(arrayed(1, 2, 3, 4));

// Or
new Collection(arrayed(1, 2, 3, 4));

// Or
Collection::make(arrayed(1, 2, 3, 4));
```

Laravel Response accepts `Arrayed`:

```
response()->json(arrayed(1, 2, 3)->flip());
```

#### Special methods

[](#special-methods)

New 🎉 `tap()` method allows other actions on the last resulting `Arrayed` instance without mutating the last `Arrayed` result:

```
arrayed(1, 2, 3)
    ->tap(function ($arrd) {
        logger('Array has '.$arrd->count());
    });
```

Others
------

[](#others)

If any operation normally returns an array, the return value will give `Arrayed` instance so that other methods can be chained on them otherwise a non-array value is returned as can be seen that `sum()` returns an integer in the example below:

Example:

```
arrayed(['a' => 1, 'b' => 2])
    ->values() // returns array, we can chain
    ->sum(); // returns an integer, we cannot chain
```

You can work on a result (if its an array'ed value) by passing a closure/callable function to `result()` method:

```
arrayed(['a' => 'name', 'b' => 'age'])
    ->values()
    ->result(fn($val) => implode(',', $val)); //'name,age'

//Or

arrayed(['a' => 'name', 'b' => 'age'])
    ->values()(fn($val) => implode(',', $val)); //'name,age'
```

Get the original array data with `raw()` method

```
arrayed([1, 2])->raw(); //[1,2]
```

#### Piped calls

[](#piped-calls)

As at now not all `array_*` functions have been implemented. `pipe()` method helps to call custom function on the array result.

Such as `array_unique` used in this way:

```
arrayed(['a' => 'www', 'b' => 'dot', 'c' => 'www'])
    ->pipe('array_unique') // data is piped forward to `array_unique`
    ->flip()
    ->values()(); //['a', 'b']
```

> The pipe method makes use of [Piper](https://github.com/transprime-research/piper) - A PHP functional pipe'ing See `\Transprime\Arrayed\Tests\ArrayedTest`

#### Proxied calls

[](#proxied-calls)

`array_*` methods that are not yet implemented are automatically proxied to call an array method with the assumption that they accept initial array first. Example is this:

```
// ->combine() method is not yet implemented

arrayed(['a', 'b'])
    ->combine(['name', 'data'])
    ->result(); //['a' => 'name', 'b' => 'data']
```

Coming Soon
-----------

[](#coming-soon)

- Implement other `array_*` methods
- pipe into Collection with `collectPipe`

```
use Illuminate\Support\Collection;

arrayed(1,2,3)->collectPipe(function (Collection $collected) {
    return $collected->take(2)->all();
})->keys();
```

> Api implementation to be decided

APIs
----

[](#apis)

These are the API's available:

```
static Arrayed::on(...$values): ArrayedInterface; //new instance of Arrayed

Arrayed::map($callback): ArrayedInterface;

Arrayed::filter($callback = null, int $flag = 0): ArrayedInterface;

Arrayed::reduce($function, $initial = null): ArrayedInterface;

Arrayed::merge(array $array2 = null, ...$_): ArrayedInterface;

Arrayed::mergeRecursive(...$_): ArrayedInterface;

Arrayed::flip(): ArrayedInterface;

Arrayed::intersect(array $array2, ...$_): ArrayedInterface;

Arrayed::values(): ArrayedInterface;

Arrayed::keys($overwrite = true): ArrayedInterface;

Arrayed::offsetGet($offset);

Arrayed::offsetSet($offset, $value): ArrayedInterface;

Arrayed::offsetUnset($offset): ArrayedInterface;

Arrayed::sum(): int;

Arrayed::contains($needle, bool $strict = false): bool;

Arrayed::isArray(): bool;

Arrayed::keyExists($key): bool;

Arrayed::offsetExists($offset): bool;

Arrayed::empty(): bool;

Arrayed::count(): int;

Arrayed::pipe(callable $action, ...$parameters);

Arrayed::result(callable $callable = null);

Arrayed::raw(): array;

Arrayed::initial(): array; // Deprecated, use raw() instead

Arrayed::tap(Closure $closure): ArrayedInterface;

Arrayed::copy(): ArrayedInterface;

Arrayed::collect(...$with): array;

// Other Array_* methods

Arrayed::changeKeyCase(int $case = null): ArrayedInterface;

Arrayed::chunk(int $size, bool $preserve_keys = false): ArrayedInterface;

Arrayed::column($column, $index_key = null): ArrayedInterface;

Arrayed::countValues(): ArrayedInterface;

Arrayed::diffAssoc(array $array2, array ...$_): ArrayedInterface;

Arrayed::diff(array $array2, array ...$_): ArrayedInterface;

Arrayed::reverse(bool $preserve_keys = false): ArrayedInterface;

Arrayed::diffUassoc(callable $key_compare_func, array $array2, array ...$_): ArrayedInterface;

Arrayed::diffKey(array $array2, array ...$_): ArrayedInterface;
```

Additional Information
----------------------

[](#additional-information)

This package is part of a series of "Code Dare"

See other packages in this series here:

-  \[A functional PHP pipe in object-oriented way\]
-  \[A smart PHP if...elseif...else statement\]
-  \[A smart PHP try...catch statement\]
-  \[A smart Carbon + Collection package\]
-  \[Jsonable Http Request(er) package with Collections response\]

Similar packages
----------------

[](#similar-packages)

-  - Very identical, but without Piper
-  - Identical but with more actions and features
-  - Perform more than just an OOP style on Arrays
-  - array tools plus collections
-  - Pack of advanced PHP array functions
-  - A Sane PHP Array library with advance functions
- More at:

Licence
-------

[](#licence)

MIT (See LICENCE file)

###  Health Score

32

↓

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity22

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

Recently: every ~0 days

Total

14

Last Release

739d ago

Major Versions

1.x-dev → 2.0.02024-04-29

PHP version history (2 changes)1.0.0PHP &gt;=7.4

1.1.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/364011bafbabff7b8c66b670b16ae372944dd4cc555531affffd901aae53d297?d=identicon)[omitobisam](/maintainers/omitobisam)

---

Top Contributors

[![omitobi](https://avatars.githubusercontent.com/u/16482234?v=4)](https://github.com/omitobi "omitobi (134 commits)")

---

Tags

phplaravelarrayhelpersarrayedarrays

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/transprime-research-arrayed/health.svg)

```
[![Health](https://phpackages.com/badges/transprime-research-arrayed/health.svg)](https://phpackages.com/packages/transprime-research-arrayed)
```

###  Alternatives

[pragmarx/ia-arr

Laravel Illuminate Agnostic Arr

553.6M12](/packages/pragmarx-ia-arr)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)[bayfrontmedia/php-array-helpers

Helper class to provide useful array functions.

1413.4k23](/packages/bayfrontmedia-php-array-helpers)[transprime-research/piper

PHP Pipe method execution with values from chained method executions

174.6k2](/packages/transprime-research-piper)

PHPackages © 2026

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