arrayutils
  • Home
  • 📖How to use?
    • âš¡Installation
  • 📖Methods
    • âš¡Static method
      • static from()
      • static of()
      • static mapToArray()
    • âš¡Generic method
      • join()
      • every()
      • some()
      • reduce()
        • reduceRight()
      • sum()
      • pop()
      • shift()
      • includes()
      • keyExists()
      • indexOf()
      • find()
        • findIndex()
      • first()
        • keyFirst()
      • last()
        • keyLast()
      • random()
        • keyRandom()
      • splice()
    • âš¡Chain method
      • chunk()
      • column()
      • combine()
      • concat()
        • concatSoft()
      • countValues()
      • diff()
        • diffAssoc()
        • diffKey()
      • fill()
        • fillKeys()
      • filter()
      • flat()
        • flatMap()
      • flip()
      • forEach()
      • intersect()
        • intersectAssoc()
        • intersectKey()
      • keys()
      • map()
        • mapAssoc()
        • mapKey()
      • pad()
      • push()
      • replace()
      • reverse()
      • slice()
      • sort()
        • sortKey()
      • unique()
      • unshift()
      • values()
  • 📖Suffixes
    • âš¡Suffix - From
    • âš¡Suffix - As
  • links
    • 📌Github repo
    • 📌Packagist project
    • 📌Poggit project
Powered by GitBook
On this page
  • Syntax
  • Parameter
  • Return value
  • Prefixing
  • References
  1. 📖Methods
  2. ⚡Chain method

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

PreviousforEach()NextintersectAssoc()

Last updated 4 years ago

PHP: array_intersect - Manual
Logo