intersect()

The intersect() method computes the intersection with other arrays and returns the values that intersects with another array.

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

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

//General array comparison
$arrayUtils->intersect(["first", "third"]);
// expected output: ["first", "third"]

Syntax

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

Parameter

  • $iterables

    Arrays to compare.

Return value

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

Prefixing

$arrayUtils->intersectAs(iterable ...$iterables) : array;
ArrayUtils::intersectFrom(iterable $from, iterable ...$iterables) : ArrayUtils;
ArrayUtils::intersectFromAs(iterable $from, iterable ...$iterables) : array;

References

Last updated