charliekassel/array-diff

Find the difference between two array's

0.0.2 2018-02-19 14:48 UTC

This package is not auto-updated.

Last update: 2024-11-10 05:45:57 UTC


README

Coverage Status

Compute the changes between two arrays.

Work in progress.

Given two arrays:

$old = [
	'a' => 1,
	'b' => 2,
	'c' => 3
];
$new = [
	'b' => 2,
	'c' => 5
]

We should expect an output of:

$differ = new \Differ\ArrayDiff();
$difference = $differ->diff($old, $new);

var_dump($difference);

array(3) {
  'added' =>
  array(0) {
  }
  'removed' =>
  array(1) {
    'a' =>
    int(1)
  }
  'changed' =>
  array(1) {
    'c' =>
    array(2) {
      'old' =>
      int(3)
      'new' =>
      int(5)
    }
  }
}