PHPackages                             rkr/php-array-utils - 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. rkr/php-array-utils

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

rkr/php-array-utils
===================

A array-function library

0.0.1(11y ago)1111MITPHPPHP &gt;= 5.3.0

Since Jul 24Pushed 11y ago2 watchersCompare

[ Source](https://github.com/rkrx/php-array-utils)[ Packagist](https://packagist.org/packages/rkr/php-array-utils)[ Docs](http://github.com/rkrx/php-array-utils)[ RSS](/packages/rkr-php-array-utils/feed)WikiDiscussions master Synced 1mo ago

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

php-array-utils
===============

[](#php-array-utils)

A array-function library

```
$input = ['a' => 0, 'b' => 1, 'c' => 2, 'd' => 3];

arr\join($input);
# 0123

arr\join($input, ', ');
# 0, 1, 2, 3

arr\intersect($input, [1, 3]);
# [b => 1, d => 3]

arr\intersect\keys($input, ['a', 'b']);
# [a => 0, b => 1]

arr\diff($input, [1, 2]);
# [a => 0, d => 3]

arr\diff\keys($input, ['a', 'c']);
# [b => 1, d => 3]

arr\filter($input);
# [b => 1, c => 2, d => 3]

arr\filter($input, function ($val) { return $val !== 1; });
# [a => 0, c => 2, d => 3]

arr\filter\keys($input);
# [a => 0, b => 1, c => 2, d => 3]

arr\filter\keys($input, function ($key) { return $key !== 'b'; });
# [a => 0, c => 2, d => 3]

arr\filter\keysAndValues($input, function ($key, $value) { return $value === 0 || $key === 'b'; });
# [a => 0, b => 1]

arr\map($input, 'exp');
# [a => 1, b => 2.718281828459, c => 7.3890560989307, d => 20.085536923188]

arr\map($input, function ($val) { return $val + 1; });
# [a => 1, b => 2, c => 3, d => 4]

arr\map\keys($input, 'strtoupper');
# [A => 0, B => 1, C => 2, D => 3]

arr\map\keys($input, function ($key) { return dechex(ord($key)); });
# [61 => 0, 62 => 1, 63 => 2, 64 => 3]

arr\map\keysAndValues($input, function (&$key, $value) { list($value, $key) = array($key, $value); return $value; });
# [0 => a, 1 => b, 2 => c, 3 => d]

arr\map\func([[255, 128, 0], [128, 255, 0]], 'vsprintf', array('#%02X%02X%02X'), 1);
# [0 => #FF8000, 1 => #80FF00]
```

FAQ
===

[](#faq)

> Hey, all the cool kids use OOP. Isn't this library pointing in the wrong direction?

It depends either on the situation or the extent in which an array is used. In PHP, arrays are often meat in different situations. At least, $\_-variables are arrays. You can immediately wrap an Array into an ArrayObject, but then you can't use many of the features built into PHP directly. So I think I have to explain the advantages and disadvantages of each approach:

Advantage of array-functions:

- You don't have to make an object out of every array you wan't to apply certain functionality on.
- You can still use php's built in functions like array\_merge() on arrays without the need for conversion.
- You can add as many functions by yourself as you wish. You could so the same with an ArrayObject-descendant, but then you end up with a god-object with tens or hundreds of methods (Closure-bindung?).
- You can always use the array-typehint and still utilize the extensions of this library directly.

Disadvantages of array-functions:

- Everytime you pass an array as a parameter to a function/method, the whole array gets copied.
- You can utilize an inner state that can help to track changes or whatever.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

4316d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f83d7e57a4bf3f1309680dbfbbf2d022f0ee6dae64a4b3bdfbed1226f2f6bef?d=identicon)[rkr](/maintainers/rkr)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rkr-php-array-utils/health.svg)

```
[![Health](https://phpackages.com/badges/rkr-php-array-utils/health.svg)](https://phpackages.com/packages/rkr-php-array-utils)
```

###  Alternatives

[naxon/nova-field-sortable

A Laravel Nova field.

59271.0k](/packages/naxon-nova-field-sortable)[terminal42/contao-conditionalformfields

conditionalformfields extension for Contao Open Source CMS; Display form fields based on conditionis!

2168.5k1](/packages/terminal42-contao-conditionalformfields)[dusanbre/laravel-tolgee

Help with Laravel integration of Tolgee service

145.5k](/packages/dusanbre-laravel-tolgee)[cytopia/git-rewrite-author

Rewrite git author and committer history (locally and remotely).

161.6k](/packages/cytopia-git-rewrite-author)

PHPackages © 2026

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