xpaw/compare-arrays

Diffing multi dimensional arrays the easy way

2.0.0 2019-10-26 17:25 UTC

This package is auto-updated.

Last update: 2024-04-25 10:11:17 UTC


README

Compares two arrays and produces a new array of changes between these two arrays. New array will be same level deep as the input arrays, and the deepest value will be ComparedValue, which is an object describing the difference (added, removed, modified).

Optionally, use CompareArrays::Flatten() function to turn diff array into a one dimensional array which will flatten keys into a single path.

Usage:

$Differences = CompareArrays::Diff( $OldArray, $NewArray );
print_r( $Differences );

$Flattened = CompareArrays::Flatten( $Differences );
print_r( $Flattened );