PHPackages                             awssat/array-helper - 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. awssat/array-helper

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

awssat/array-helper
===================

A flexible &amp; powerful array manipulation helper for PHP

1.0(8y ago)711MITPHPPHP ~7.0

Since Mar 17Pushed 8y ago1 watchersCompare

[ Source](https://github.com/awssat/array-helper)[ Packagist](https://packagist.org/packages/awssat/array-helper)[ Docs](https://github.com/awssat/array-helper)[ RSS](/packages/awssat-array-helper/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

array-helper
============

[](#array-helper)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4a09035925aee78affa66caae1c0831a912f4c868c3dc07e7ad19969ebcf75dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6177737361742f61727261792d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/awssat/array-helper)[![Build Status](https://camo.githubusercontent.com/5aacecd481e818684a39aca2a26539cd48440da01791c995569d5de15665ca1e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6177737361742f61727261792d68656c7065722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/awssat/array-helper)[![StyleCi Status](https://camo.githubusercontent.com/66ce1cba07d4c43a8a5e0a7a097ca1e7d255ac7677f24e951a0e80cce6777ffe/68747470733a2f2f7374796c6563692e696f2f7265706f732f3132353333343439362f736869656c64)](https://styleci.io/repos/125334496)

⚡️ A flexible, simple &amp; yet powerful array manipulation helper for PHP. It gives you the magic of method chaining and it's easier and shorter to be included in views. It Supports most of [PHP built-in array functions](http://php.net/manual/en/book.array.php)

```
arr([' ', 'hi ', null, '  welcome'])->map('trim')->filter()->get()
>> ['hi', 'welcome']
```

Features
--------

[](#features)

- Support All PHP array functions.
- Short methods names, no need to write "array\_" like array\_map can be only map(..)
- Array items can be retrireve or updated as properties or keys \[-&gt;key or \[key\] \]
- Support powefull conditional methods. if, else, if{AnyMethod}, endif.
- Support camelCase and snake-case methods name.
- Useful new methods like equal, exists .. etc

Install/Use
-----------

[](#installuse)

You can install the package via composer locally in your project folder:

```
$ composer require awssat/array-helper
```

After installing it, just start using the helper `arr([...])` or `ArrayHelper::make([...])`

Examples
--------

[](#examples)

Use any array function, no need for "array\_", if you like it you can use it as in array\_filter or arrayFilter .. all will work.

```
$x = arr(['', 'item', null, 'item2'])->filter()->get()
>> ['item', 'item2']
```

You can use conditions, if(function() {...}), if{AnyMethod}, else(), endif()

```
$x = arr(['item', 'item2', null])
    ->ifContains(null)
        ->filter()
    ->endif()
    ->get()
```

you may also use useful method with `if` like `ifEmpty`, `ifKeyExists` or `ifEqual` etc.

get() will return all items, while get(index) return a item in the array. all() is alias for get(all, true) which will ignore conditions and force return of items anyway.

The example above can be shortened using all() like this:

```
$x = arr(['item', 'item2', null])
    ->ifContains(null)
        ->filter()
    ->all()
```

You can use do(callback) to run a callback on the array.

```
$x = arr(['item ', 'item2'])
    ->do(function() {
        return $this->map('trim');
    })
    ->all()
```

PHP built-in array\_map, array\_walk, array\_filter, and array\_reduce are the best!

array\_map to loop through all items and change them.

```
$array->map(function($item) {
         return 'Hello: '. strip_tags($item) . ' !';
    });
```

or for simple functions use, `$array->map('trim')`

array\_walk can be used for looping without changing items

```
$array->walk(function($item, $key) {
            print "$key: $item\n";
    });
```

or if you want to change the values

```
$array->walk(function(&$item, $key) {
            $item = $item * 2;
        });
```

array\_filter is great for filtering an array

```
$array->filter(function($item) {
            return $item > 5;
        });
```

or just `$array->filter()` to remove any value equal to FALSE.

Tests
-----

[](#tests)

Simply use:

```
$ composer test
```

Credits
-------

[](#credits)

- [Abdulrahman M.](https://github.com/abdumu)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3027d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/114794?v=4)[abdulrahman](/maintainers/abdumu)[@abdumu](https://github.com/abdumu)

---

Top Contributors

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

---

Tags

arrayarray-filterarray-helperarray-manipulationsarray-methodsarray-processingarrayscallbackchainable-methodsendifloopmethod-chainingphphelperarraymanipulationarrayspipechain

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/awssat-array-helper/health.svg)

```
[![Health](https://phpackages.com/badges/awssat-array-helper/health.svg)](https://phpackages.com/packages/awssat-array-helper)
```

###  Alternatives

[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4915.7M18](/packages/voku-arrayy)[bocharsky-bw/arrayzy

A native PHP arrays easy manipulation library in OOP way.

38427.0k](/packages/bocharsky-bw-arrayzy)[minwork/array

Pack of advanced array functions specifically tailored for: associative (assoc) array, multidimensional array, array of objects and handling nested array elements

66268.2k5](/packages/minwork-array)[spatie/array-functions

Some handy array helpers

24564.6k2](/packages/spatie-array-functions)[fg/parkour

A collection of utilities to manipulate arrays.

14490.6k3](/packages/fg-parkour)[sarhan/php-flatten

Flattens multidimensional arrays, traversables and vars into one dimensional array.

21182.2k1](/packages/sarhan-php-flatten)

PHPackages © 2026

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