PHPackages                             mulertech/array-manipulation - 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. mulertech/array-manipulation

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

mulertech/array-manipulation
============================

This class manipulates and organizes arrays

v2.0.2(1y ago)04221MITPHPPHP ^8.2CI passing

Since Oct 27Pushed 1mo ago1 watchersCompare

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

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

ArrayManipulation
=================

[](#arraymanipulation)

---

[![Latest Version on Packagist](https://camo.githubusercontent.com/b9937c31c9fbbdfcc1fa2f8367d3d8acbd124d1232b8695944844aedd088d113/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d756c6572746563682f61727261792d6d616e6970756c6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mulertech/array-manipulation)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d297f15cadb5dd68e6faea824a11f0d43d2cece1d55e526cc74141f9a63f8499/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d756c6572746563682f61727261792d6d616e6970756c6174696f6e2f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mulertech/array-manipulation/actions/workflows/tests.yml)[![GitHub PHPStan Action Status](https://camo.githubusercontent.com/a398e08a255a5e6c38b5c81cf9137fa078f42dda88bc86da5ad263a8eec034af/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d756c6572746563682f61727261792d6d616e6970756c6174696f6e2f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/mulertech/array-manipulation/actions/workflows/phpstan.yml)[![GitHub Security Action Status](https://camo.githubusercontent.com/05885ca1dadb5f39e54ad2f0c600791573dc7e0b9e7c6d29a4712b5e657593af/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d756c6572746563682f61727261792d6d616e6970756c6174696f6e2f73656375726974792e796d6c3f6272616e63683d6d61696e266c6162656c3d7365637572697479267374796c653d666c61742d737175617265)](https://github.com/mulertech/array-manipulation/actions/workflows/security.yml)[![Total Downloads](https://camo.githubusercontent.com/4a4d18ac2d9032721afa1a8f33b6a0d967dea24559b1dcdba886a07e50627799/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d756c6572746563682f61727261792d6d616e6970756c6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mulertech/array-manipulation)[![Test Coverage](https://raw.githubusercontent.com/mulertech/array-manipulation/badge/badge-coverage.svg)](https://packagist.org/packages/mulertech/array-manipulation)

---

This class manipulates and organizes arrays

---

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

[](#installation)

###### *Two methods to install Application package with composer :*

[](#two-methods-to-install-application-package-with-composer-)

1.

Add to your "**composer.json**" file into require section :

```
"mulertech/array-manipulation": "^2.0"

```

and run the command :

```
php composer.phar update

```

2.

Run the command :

```
php composer.phar require mulertech/array-manipulation "^2.0"

```

---

Usage
-----

[](#usage)

###### *Check if an array is associative or not :*

[](#check-if-an-array-is-associative-or-not-)

```
ArrayManipulation::isAssoc([['name' => 'john'], ['name' => 'jack']]);

// true

```

###### *Check if an array is list or not :*

[](#check-if-an-array-is-list-or-not-)

```
ArrayManipulation::isList([1, 2, 3, 4, 5]);

// true

```

###### *List of duplicates values :*

[](#list-of-duplicates-values-)

```
ArrayManipulation::listOfDuplicates([1, 2, 3, 33, 8, 33, 4, 806, 402, 806]);

// [33, 806]

```

###### *Add a "number" key (or another name) and its number into an associative array :*

[](#add-a-number-key-or-another-name-and-its-number-into-an-associative-array-)

```
ArrayManipulation::addNumberKey([['name' => 'john'], ['name' => 'jack']]);

// [['name' => 'john', 'number' => 1], ['name' => 'jack', 'number' => 2]]

```

###### *Find differences by name (it can be used to compare old and new array) :*

[](#find-differences-by-name-it-can-be-used-to-compare-old-and-new-array-)

```
$first =  ['akey' => 'avalue', 'anotherkey' => 'secondvalue',  'thirdkey' => 'oldvalue'];
$second = ['akey' => 'avalue', 'anotherkey' => 'notsamevalue', 'thirdkey' => 'newvalue'];
ArrayManipulation::findDifferencesByName($first, $second);

// ['anotherkey' => ['secondvalue', 'notsamevalue'], 'thirdkey' => ['oldvalue', 'newvalue']];

```

###### *Order by one or two column (you can choose the name of the columns and the asc or desc order for each) :*

[](#order-by-one-or-two-column-you-can-choose-the-name-of-the-columns-and-the-asc-or-desc-order-for-each-)

```
$array = [
    ['firstcolumn' => 'apple', 'secondcolumn' => 'zorro', 'thirdcolumn' => 'masked man'],
    ['firstcolumn' => 'banana', 'secondcolumn' => 'superman', 'thirdcolumn' => 'masked man'],
    ['firstcolumn' => 'cherry', 'secondcolumn' => 'batman', 'thirdcolumn' => 'masked man'],
    ['firstcolumn' => 'coconut', 'secondcolumn' => 'alibaba', 'thirdcolumn' => 'unmasked man'],
    ['firstcolumn' => 'pineapple', 'secondcolumn' => 'Tom sawyer', 'thirdcolumn' => 'unmasked man']
];

ArrayManipulation::orderByColumn($array, 'thirdcolumn', 'desc', 'secondcolumn'); // default order is asc

// result :
[
    ['firstcolumn' => 'coconut', 'secondcolumn' => 'alibaba', 'thirdcolumn' => 'unmasked man'],
    ['firstcolumn' => 'pineapple', 'secondcolumn' => 'Tom sawyer', 'thirdcolumn' => 'unmasked man'],
    ['firstcolumn' => 'cherry', 'secondcolumn' => 'batman', 'thirdcolumn' => 'masked man'],
    ['firstcolumn' => 'banana', 'secondcolumn' => 'superman', 'thirdcolumn' => 'masked man'],
    ['firstcolumn' => 'apple', 'secondcolumn' => 'zorro', 'thirdcolumn' => 'masked man'],
];

```

###### *Add a value into an array by indicated the key, the value and keys up to final key,*

[](#add-a-value-into-an-array-by-indicated-the-key-the-value-and-keys-up-to-final-key)

###### *it can create the final key or add the value into an array in this final key :*

[](#it-can-create-the-final-key-or-add-the-value-into-an-array-in-this-final-key-)

1. Add a key and its value :

```
$array = [
    'subtest1' => [
        'subsubtest1' => 'a value',
        'subsubtest2' => 'b value',
        'subsubtest3' => 'c value'
    ],
    'subtest2' => [
        'subsubsecondtest1' => 'another value a',
        'subsubsecondtest2' => 'another value b',
        'subsubsecondtest3' => 'another value c',
        'subsubsecondtest4' => 'another value d',
    ],
    'subtest3' => [
        'othersub' => [
            'subsubsub1' => 'value a',
            'subsubsub2' => 'value b'
        ]
    ]
];

ArrayManipulation::addKeyValue($array, 'keytoaddvalue', ['a first value'], 'subtest3', 'othersub');

// result :
[
    'subtest1' => [
        'subsubtest1' => 'a value',
        'subsubtest2' => 'b value',
        'subsubtest3' => 'c value'
    ],
    'subtest2' => [
        'subsubsecondtest1' => 'another value a',
        'subsubsecondtest2' => 'another value b',
        'subsubsecondtest3' => 'another value c',
        'subsubsecondtest4' => 'another value d',
    ],
    'subtest3' => [
        'othersub' => [
            'subsubsub1' => 'value a',
            'subsubsub2' => 'value b',
            'keytoaddvalue' => ['a first value']
        ]
    ]
];

```

2. Add a value to an existing key :

```
$array = [
    'subtest1' => [
        'subsubtest1' => 'a value',
        'subsubtest2' => 'b value',
        'subsubtest3' => 'c value'
    ],
    'subtest2' => [
        'subsubsecondtest1' => 'another value a',
        'subsubsecondtest2' => 'another value b',
        'subsubsecondtest3' => 'another value c',
        'subsubsecondtest4' => 'another value d',
    ],
    'subtest3' => [
        'othersub' => [
            'subsubsub1' => 'value a',
            'subsubsub2' => 'value b',
            'keytoaddvalue' => ['a first value']
        ]
    ]
];

ArrayManipulation::addKeyValue($array, 'keytoaddvalue', 'an other value', 'subtest3', 'othersub');

// result :
[
    'subtest1' => [
        'subsubtest1' => 'a value',
        'subsubtest2' => 'b value',
        'subsubtest3' => 'c value'
    ],
    'subtest2' => [
        'subsubsecondtest1' => 'another value a',
        'subsubsecondtest2' => 'another value b',
        'subsubsecondtest3' => 'another value c',
        'subsubsecondtest4' => 'another value d',
    ],
    'subtest3' => [
        'othersub' => [
            'subsubsub1' => 'value a',
            'subsubsub2' => 'value b',
            'keytoaddvalue' => ['a first value', 'an other value']
        ]
    ]
];

```

###### *Remove a key and its value into an array by indicated the key and keys up to final key :*

[](#remove-a-key-and-its-value-into-an-array-by-indicated-the-key-and-keys-up-to-final-key-)

```
$array = [
            'subtest1' => [
                'subsubtest1' => 'a value',
                'subsubtest2' => 'b value',
                'subsubtest3' => 'c value'
            ],
            'subtest2' => [
                'subsubsecondtest1' => 'another value a',
                'subsubsecondtest2' => 'another value b',
                'subsubsecondtest3' => 'another value c',
                'subsubsecondtest4' => 'another value d',
            ],
            'subtest3' => [
                'othersub' => [
                    'subsubsub1' => 'value a',
                    'subsubsub2' => 'value b',
                    'keytoremove' => 'goodbye'
                ]
            ]
        ];

ArrayManipulation::removeKey($array, 'subtest3', 'othersub', 'keytoremove');

// Result :
[
    'subtest1' => [
        'subsubtest1' => 'a value',
        'subsubtest2' => 'b value',
        'subsubtest3' => 'c value'
    ],
    'subtest2' => [
        'subsubsecondtest1' => 'another value a',
        'subsubsecondtest2' => 'another value b',
        'subsubsecondtest3' => 'another value c',
        'subsubsecondtest4' => 'another value d',
    ],
    'subtest3' => [
        'othersub' => [
            'subsubsub1' => 'value a',
            'subsubsub2' => 'value b',
        ]
    ]
];

```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance70

Regular maintenance activity

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 84.8% 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 ~119 days

Recently: every ~208 days

Total

8

Last Release

465d ago

Major Versions

v1.0.4 → v2.0.02024-10-27

PHP version history (4 changes)v1.0.2PHP ^7.3

v1.0.4PHP &gt;=7.3

v2.0.0PHP &gt;=8.2

v2.0.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/357d309912bbc5318d9877d1369987d2390c8e034b637e9f20671c28b09b5119?d=identicon)[mulertech](/maintainers/mulertech)

---

Top Contributors

[![mulertech](https://avatars.githubusercontent.com/u/57788787?v=4)](https://github.com/mulertech "mulertech (39 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

open-source

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mulertech-array-manipulation/health.svg)

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

###  Alternatives

[sonata-project/seo-bundle

Symfony SonataSeoBundle

1442.7M41](/packages/sonata-project-seo-bundle)[nabao/laravel-lock

高性能, 分布式, 并发抢占锁, 队列锁

271.5k](/packages/nabao-laravel-lock)

PHPackages © 2026

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