2017 © Pedro PelĂĄez
 

library array-diff-multidimensional

Compare the difference between two multidimensional arrays

image

rogervila/array-diff-multidimensional

Compare the difference between two multidimensional arrays

  • Friday, April 13, 2018
  • by rogervila
  • Repository
  • 2 Watchers
  • 8 Stars
  • 6,879 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 4 Open issues
  • 4 Versions
  • 190 % Grown

The README.md

Array Diff Multidimensional

Build Status StyleCI Total Downloads Latest Stable Version License, (*1)

Works like the PHP array_diff() function, but with multidimensional arrays., (*2)

Install

Via composer:, (*3)

composer require rogervila/array-diff-multidimensional

Usage

use Rogervila\ArrayDiffMultidimensional;

$new = [
    'a' => 'b',
    'c' => [
        'd' => 'e',
        'f' => 'Hello',
    ],
];

$old = [
    'a' => 'b',
    'c' => [
        'd' => 'e',
        'f' => 'Goodbye',
    ],
];

// Compare the arrays by calling the 'compare' class method
$result = ArrayDiffMultidimensional::compare($new, $old)

// Or by calling the global helper function
$result = array_diff_multidimensional($new, $old)


var_dump($result);

The result of comparing $new with $old will return a new array with the changes:, (*4)

[
    'c' => [
        'f' => 'Hello'
    ],
]

Strict vs. Loose comparisons

Comparisons are strict by default, but you can specify that you want to make a loose comparison passing a boolean as the third parameter for compare method or calling the looseComparison, (*5)

// Passing 'false' as a third parameter will deactivate the strict comparison mode
ArrayDiffMultidimensional::compare($new, $old, false);

array_diff_multidimensional($new, $old, false);


// This method call is equivalent
ArrayDiffMultidimensional::looseComparison($new, $old);

Also, a strictComparison method is available for more clarity, (*6)

// Comparisons are strict by default
ArrayDiffMultidimensional::compare($new, $old);

array_diff_multidimensional($new, $old);


// This method call is equivalent
ArrayDiffMultidimensional::strictComparison($new, $old);

License

Array Diff Multidimensional is an open-sourced package licensed under the MIT license., (*7)

The Versions

13/04 2018

dev-master

9999999-dev

Compare the difference between two multidimensional arrays

  Sources   Download

MIT

The Development Requires

by Roger VilĂ 

14/12 2017

dev-sonarcloud

dev-sonarcloud

Compare the difference between two multidimensional arrays

  Sources   Download

MIT

The Development Requires

by Roger VilĂ 

20/02 2017

dev-analysis-86LD0a

dev-analysis-86LD0a

Compare the difference between two multidimensional arrays

  Sources   Download

MIT

The Development Requires

by Roger VilĂ 

20/02 2017

1.0.0

1.0.0.0

Compare the difference between two multidimensional arrays

  Sources   Download

MIT

The Development Requires

by Roger VilĂ