Skip to content

charliekassel/array-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArrayDiff

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