lukaszmakuch / array-utils-comparator
Checks whether two arrays contain equal elements.
v1.0.0
2015-08-22 08:58 UTC
Requires (Dev)
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: 4.7.*
This package is not auto-updated.
Last update: 2025-01-08 11:18:11 UTC
README
Allows to compare arrays.
Usage
arraysHoldEqualElements
By default this method checks whether two arrays contain equal elements by strict comparison (===).
ArrayComparator::arraysHoldEqualElements([1, 2, 3], [1, 2, 3]); //true ArrayComparator::arraysHoldEqualElements([1, 2, 3], [1, 2, 3, 4]); //false ArrayComparator::arraysHoldEqualElements([1, 2, 3], [1, 3, 2]); //true
But it's also possible to provide custom value compare function.
ArrayComparator::arraysHoldEqualElements( [1, 2, 3], [2, 4, 6], function ($arr1Elem, $arr2Elem) { return ((2 * $arr1Elem) === $arr2Elem); } ); //true
Installation
Use composer to get the latest version:
$ composer require lukaszmakuch/array-utils-comparator