PHPackages                             mufuphlex/array-util - 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. mufuphlex/array-util

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

mufuphlex/array-util
====================

Array utils - smart&amp;fast array helpers

1.0.0(3y ago)223MITPHPPHP &gt;=8.0

Since Nov 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Mufuphlex/array-util)[ Packagist](https://packagist.org/packages/mufuphlex/array-util)[ RSS](/packages/mufuphlex-array-util/feed)WikiDiscussions master Synced 2mo ago

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

mufuphlex array-util
====================

[](#mufuphlex-array-util)

[![Latest Stable Version](https://camo.githubusercontent.com/9b7bd9037818dadef5b1a35bbbb557dc6e765274e38a35f1e3cf9fe291e16832/68747470733a2f2f706f7365722e707567782e6f72672f6d75667570686c65782f61727261792d7574696c2f762f737461626c65)](https://packagist.org/packages/mufuphlex/array-util)[![License](https://camo.githubusercontent.com/b6cbc81c37bddacd8b51419331a798a432dc14445d3873e293489cb550efebbb/68747470733a2f2f706f7365722e707567782e6f72672f6d75667570686c65782f61727261792d7574696c2f6c6963656e7365)](https://packagist.org/packages/mufuphlex/array-util)

Array utils - smart&amp;fast array helpers.

These helpers, among other things, provide a **significantly improved** (about **10-30 times faster**) analogues of built-in PHP array functions, like `unique()` or `intersect()`.

### `unique()` function

[](#unique-function)

This is an improved (**30 times faster!**) implementation of standard `array_unique()` PHP function.

```
$arr = [1,2,3,1,2,3];
$unique = \Mufuphlex\Util\ArrayUtil::unique($arr);
// [1,2,3]
```

### `intersect()` function

[](#intersect-function)

This is an improved (**10 times faster!**) implementation of standard `array_intersect()` PHP function.

```
$a = [1,2,3];
$b = [2,3,4];
$c = [3,4,5];
$result = \Mufuphlex\Util\ArrayUtil::intersect($a, $b, $c);
// [3]
```

### `cutBy*()` functions

[](#cutby-functions)

If you need to remove particular elements from an array by elements' keys, `cutByWhitelist(array $array, array $map)` and `cutByBlacklist(array $array, array $map)` can be very useful. `cutByWhitelist()` **leaves** in `$array` only elements which are listed in the `$map` and `cutByBlacklist()` - just in opposite - **removes** from `$array` elements listed in `$map`. Moreover, these functions can not only remove, but also modify `$array`'s members via callbacks - smth like an extended version of standard PHP function `array_walk()`.

**How to use it?**

Let's consider the following sample array:

```
$array = [
	'result' => [
		'one' => [
			'param 1' => 1,
			'param 2' => 2,
			'param 3' => 3,
		],
		'another' => [
			'param 1' => 4,
			'param 2' => 5,
			'param 3' => 6,
		],
		'another one' => [
			'param 1' => 7,
			'param 2' => 8,
			'param 3' => 9,
		]
	],
	'errors' => [
		'form' => [
			'field 1' => [
				0 => 'error 1',
				1 => 'error 2'
			],
			'field 2' => [
				0 => 'error 3',
				1 => 'error 4 '
			]
		],
		'logic' => [
			0 => 'logic error 1',
			1 => 'logic error 2'
		]
	],
	0 => [
		0 => 'item 1',
		1 => 'item 2'
	],
	1 => [
		0 => 'item 3',
		1 => 'item 4'
	],
	'123 - numeric containing' => [
		0 => 'item 5',
		1 => 'item 6'
	],
	'not numeric containing' => [
		0 => 'item 5',
		1 => 'item 6'
	],

];
```

1. Leave/remove elements in/from `array.result\*` with keys containing only `one` or only `another`: ```
    $map = [
    	'result' => [
    		'/^(?:one|another)$/' => true
    	]
    ];
    ```
2. Leave/remove only elements in/from `array.errors.logic`: ```
    $map = [
    	'errors' => [
    		'logic' => true
    	]
    ];
    ```
3. Leave/remove only elements with key `0` from `array.errors.form.field \*.\*`: ```
    $map = [
    	'errors' => [
    		'form' => [
    			'field \d+' => [
    				0 => true
    			]
    		]
    	]
    ];
    ```
4. Leave/remove elements in/from `array.result.\*` with keys `param 3` and/or modify these elements' values by adding 5: ```
    $map = [
    	'result' => [
    		'/.+/' => [
    			'param 3' => function($arg){ return $arg+=5; }
    		]
    	]
    ];
    ```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

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

Total

4

Last Release

1147d ago

Major Versions

0.1.2 → 1.0.02023-03-25

PHP version history (2 changes)0.1PHP &gt;=5.3.9

1.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b57fd7e929017fbdb799019b67b2254fb426154c2299c5ee852cf2713538782?d=identicon)[AlexMiroshnikov](/maintainers/AlexMiroshnikov)

---

Top Contributors

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

---

Tags

arrayarray\_walkarray\_maparray utilarray cutarray intersectarray uniquesmart intersectsmart uniquefast intersectfast unique

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mufuphlex-array-util/health.svg)

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

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