byfareska/array-diff-callable

array_diff like helper with callable support

v1.0.0 2025-02-25 08:59 UTC

This package is auto-updated.

Last update: 2025-02-27 12:11:01 UTC


README

Compares two arrays like array_diff do but with a custom comparison function.

\Byfareska\Difference\Diff::compare(
    ['foo', 'bar', 'baz'],
    ['foo', 'baz'],
    static fn ($a, $b) => $a === $b
);
// => ['bar']

You can also skip the comparison function to try it compare using built-in comparisons by methods and properties (if exists):

  • getId()
  • id
  • __toString()
  • json_encode for array and stdClass

Installation

composer require byfareska/array-diff-callable