PHPackages                             fortress/array-comparison - 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. fortress/array-comparison

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

fortress/array-comparison
=========================

Compare two arrays and return differences

1.0.0(3y ago)03MITPHPPHP ^8.1

Since Jul 22Pushed 3y agoCompare

[ Source](https://github.com/Fortress-Digital/array-comparison)[ Packagist](https://packagist.org/packages/fortress/array-comparison)[ Docs](https://github.com/:vendor_slug/:package_slug)[ RSS](/packages/fortress-array-comparison/feed)WikiDiscussions main Synced 1mo ago

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

Array Comparison
================

[](#array-comparison)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b5c97c30f1138e2c1707aa8a67287eac2a654c204c6826786521a1ffc27c6ff3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f7274726573732f61727261792d636f6d70617269736f6e2e737667)](https://packagist.org/packages/fortress/array-comparison)[![Tests](https://github.com/Fortress-Digital/array-comparison/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/Fortress-Digital/array-comparison/actions/workflows/run-tests.yaml)

Compare two associative arrays and see the difference between them.

Supports nested associative arrays and array collections.

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

[](#installation)

You can install the package via composer:

```
composer require fortress/array-comparison
```

Usage
-----

[](#usage)

```
$expected = [
    'object' => [
        'to_be_removed' => [
            'item1',
            'item2',
        ],
        'to_be_changed' => [
            'item3',
            'item4',
        ]
    ]
];

$actual = [
    'object' => [
        'to_be_added' => [
            'item3',
            'item4',
        ],
        'to_be_changed' => [
            'item5',
            'item6',
        ],
    ]
];

$comparison = new Fortress\ArrayComparison();
$comparison->getDiff($expected, $actual);
```

Results in:

```
[
    'added' => [
        'object' => [
            'to_be_added' => [
                'item3',
                'item4',
            ],
        ]
    ],
    'removed' => [
        'object' => [
            'to_be_removed' => [
                'item1',
                'item2',
            ],
        ]
    ],
    'changed' => [
        'object' => [
            'to_be_changed' => [
                'old' => [
                    'item3',
                    'item4',
                ],
                'new' => [
                    'item5',
                    'item6',
                ],
            ],
        ],
    ],
]

```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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

1396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/610bdb821ab68c17414a0c06451188e70fdff24b6b131a9e82d96ebf9b8c1541?d=identicon)[brash-creative](/maintainers/brash-creative)

---

Top Contributors

[![paul-crashley](https://avatars.githubusercontent.com/u/307618?v=4)](https://github.com/paul-crashley "paul-crashley (12 commits)")

---

Tags

arraycomparisonfortressarray-comparison

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/fortress-array-comparison/health.svg)

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

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