PHP code example of charliekassel / array-diff

1. Go to this page and download the library: Download charliekassel/array-diff library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

charliekassel / array-diff example snippets


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

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