fortress/array-comparison
最新稳定版本:1.0.0
Composer 安装命令:
composer require fortress/array-comparison
包简介
Compare two arrays and return differences
README 文档
README
Compare two associative arrays and see the difference between them.
Supports nested associative arrays and array collections.
Installation
You can install the package via composer:
composer require fortress/array-comparison
Usage
$expected = [ 'object' => [ 'to_be_removed' => [ 'item1', 'item2', ], 'to_be_changed' => [ 'item3', 'item4', ] ] ]; $actual = [ 'object' => [ 'to_be_added' => [ 'item3', 'item4', ], 'to_be_changed' => [ 'item5', 'item6', ], ] ]; $comparison = new Fortress\ArrayComparison(); $comparison->getDiff($expected, $actual);
Results in:
[
'added' => [
'object' => [
'to_be_added' => [
'item3',
'item4',
],
]
],
'removed' => [
'object' => [
'to_be_removed' => [
'item1',
'item2',
],
]
],
'changed' => [
'object' => [
'to_be_changed' => [
'old' => [
'item3',
'item4',
],
'new' => [
'item5',
'item6',
],
],
],
],
]
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-22