diffAssoc()

The diffAssoc() method all similar to diff(), but this applies with additional index check

Example.php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["first" => 1, "second" => 2, "third" => 3]);

//General array comparison
$arrayUtils->diffAssoc(["first" => 404, "second" => 2]);
// expected output: ["first" => 1, "third" => 3]

Syntax

$arrayUtils->diffAssoc(iterable ...$iterables) : ArrayUtils;

Parameter

  • $iterables

    Arrays to compare.

Return value

  • A array containing all the entries that are not present in any of the other arrays. (Keys are preserved)

Prefixing

$arrayUtils->diffAssocAs(iterable ...$iterables) : array;
ArrayUtils::diffAssocFrom(iterable $from, iterable ...$iterables) : ArrayUtils;
ArrayUtils::diffAssocFromAs(iterable $from, iterable ...$iterables) : array;

References

Last updated