All Projects → rogervila → array-diff-multidimensional

rogervila / array-diff-multidimensional

Licence: other
Compare the difference between two multidimensional arrays in PHP

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to array-diff-multidimensional

pg-diff
PostgreSQL schema and data comparing tool
Stars: ✭ 39 (-35%)
Mutual labels:  diff, compare
HandySub
Download Subtitle from Subscene and other sources
Stars: ✭ 42 (-30%)
Mutual labels:  diff, compare
VBA-Arrays
😎 Array functions that are similar JavaScript functions. Example: Push, Pop, Shift, Unshift, Sort, length, toString.
Stars: ✭ 48 (-20%)
Mutual labels:  array, multidimensional
Deep Object Diff
Deep diffs two objects, including nested structures of arrays and objects, and returns the difference. ❄️
Stars: ✭ 515 (+758.33%)
Mutual labels:  diff, array
vscode-diff
Compare two folders in Visual Studio Code
Stars: ✭ 66 (+10%)
Mutual labels:  diff, compare
array-sort-by
Powerful mechanism to sort arrays or array of objects by one or more properties. You can also specify a custom comparer function.
Stars: ✭ 37 (-38.33%)
Mutual labels:  array, compare
Compare-UserJS
PowerShell script for comparing user.js (or prefs.js) files.
Stars: ✭ 79 (+31.67%)
Mutual labels:  diff, compare
npmfs
javascript package inspector
Stars: ✭ 90 (+50%)
Mutual labels:  diff, compare
spdx-license-ids
a list of SPDX license identifiers
Stars: ✭ 29 (-51.67%)
Mutual labels:  array
magit-diff-flycheck
Flycheck for Magit diff buffers!
Stars: ✭ 24 (-60%)
Mutual labels:  diff
array
Pack of advanced PHP array functions
Stars: ✭ 45 (-25%)
Mutual labels:  array
github-compare
Compares two github projects
Stars: ✭ 19 (-68.33%)
Mutual labels:  compare
rxjs-ninja
RxJS Operators for handling Observable strings, numbers, booleans and more
Stars: ✭ 68 (+13.33%)
Mutual labels:  array
stock-prices
Analyzing stock prices with Fortran arrays
Stars: ✭ 24 (-60%)
Mutual labels:  array
ra-ra
A C++20 array / expression template library with some J/APL features
Stars: ✭ 22 (-63.33%)
Mutual labels:  array
vcdiff
Heavily optimized .NET Core vcdiff library
Stars: ✭ 16 (-73.33%)
Mutual labels:  diff
arr-flatten
Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
Stars: ✭ 55 (-8.33%)
Mutual labels:  array
MCUCapture
Utility for plotting array data from MCU RAM
Stars: ✭ 22 (-63.33%)
Mutual labels:  array
tmux-eaw-fix
tmux 2.6 以降において East Asian Ambiguous Character を全角文字の幅で表示する
Stars: ✭ 16 (-73.33%)
Mutual labels:  diff
ss-search
The most basic, yet powerful text search.
Stars: ✭ 41 (-31.67%)
Mutual labels:  array

Array Diff Multidimensional

Build Status StyleCI Total Downloads Latest Stable Version License

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

Install

Via composer:

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:

[
	'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

// 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

// 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].