niko9911 / diff-multidimensional-array
Creating diff between two multidimensional arrays
1.0.1
2019-02-28 11:42 UTC
Requires
- php: ^7.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2
- phpunit/phpunit: ^7 || ^8
This package is auto-updated.
Last update: 2024-12-14 22:24:15 UTC
README
Based on PHP array_diff() function, but will have support for multidimesional arrays. PHP.net Bug report.
Install
Via composer:
composer require niko9911/diff-multidimensional-array
Usage
Will work like normal PHP array_diff_assoc($new, $old, $older). Basic usage is following:
Multidimensional::diff(array $array1 , array $array2 [,array $...]): array
Example:
<?php declare(strict_types=1); use Niko9911\ArrayDiff\Multidimensional; $newResults = [ 'zoo' => 'pets', 'foo' => [ 'cat', 'dog', 'php' ], ]; $oldResults = [ 'zoo' => 'pets', 'foo' => [ 'php' ], ]; var_dump(Multidimensional::diff($new,$old)); /** Will result: array(1) { 'foo' => array(3) { [0] => string(3) "cat" [1] => string(3) "dog" [2] => string(3) "php" } } */
License
Licensed under the MIT license.