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

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

melvdouc/array-utils
====================

Some JavaScript-inspired array utility functions for my personal use.

v1.0.0(2y ago)07MITPHPPHP &gt;=7.0

Since Aug 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/MelvDouc/php-array-utils)[ Packagist](https://packagist.org/packages/melvdouc/array-utils)[ RSS](/packages/melvdouc-array-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Array Utils
===========

[](#array-utils)

Some JavaScript-inspired array utility functions for my personal use.

Examples
--------

[](#examples)

### bubbleSort

[](#bubblesort)

```
$lotteryNumbers = [15, 4, 16, 42, 23, 8];
ArrayUtils::bubbleSort($lotteryNumbers, function (int $a, int $b) {
  return $a - $b;
}); // [ 4, 8, 15, 16, 23, 42 ]
```

### every &amp; some

[](#every--some)

```
$numbers = [1, 2, 3];

function isEven(int $n)
{
  return $n % 2 === 0;
}

ArrayUtils::every($numbers, "isEven"); // false
ArrayUtils::some($numbers, "isEven"); // true
```

### find

[](#find)

```
$firstEvenNumber = ArrayUtils::find($numbers, "isEven"); // 2
```

### flatten

[](#flatten)

```
ArrayUtils::flatten([1, [2, [3], 4]]);
// ↪ [ 1, 2, [ 3 ], 4 ]
ArrayUtils::flatten([1, [2, [3], 4]], INF);
// ↪ [ 1, 2, 3, 4 ]
```

### from

[](#from)

```
$squareNumbers = ArrayUtils::from(3, fn ($i) => ($i + 1) ** 2);
// ↪ [ 1, 4, 9 ]
```

### groupBy

[](#groupby)

```
$numbersByParity = ArrayUtils::groupBy($numbers, function (int $n) {
  return ($n % 2 === 0) ? "even" : "odd";
});
// ↪ [ "odd" => [ 1, 3 ], "even" => [ 2 ] ]
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

992d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

arrayarray utilsarray methods

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
