intersectKey()

The intersectKey() method all similar to intersect(), but this applies to keys

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

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

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

Syntax

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

Parameter

  • $iterables

    Arrays to compare.

Return value

  • A array containing all of the values that intersects with another array.

Prefixing

$arrayUtils->intersectkeyAs(iterable ...$iterables) : array;
ArrayUtils::intersectkeyFrom(iterable $from, iterable ...$iterables) : ArrayUtils;
ArrayUtils::intersectkeyFromAs(iterable $from, iterable ...$iterables) : array;

References

Last updated