# intersect()

{% code title="Example.php" %}

```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"]
```

{% endcode %}

## Syntax

```php
$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

```php
$arrayUtils->intersectAs(iterable ...$iterables) : array;
```

```php
ArrayUtils::intersectFrom(iterable $from, iterable ...$iterables) : ArrayUtils;
```

```php
ArrayUtils::intersectFromAs(iterable $from, iterable ...$iterables) : array;
```

## References

{% embed url="<https://www.php.net/manual/en/function.array-intersect>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://arrayutils.docs.present.kim/methods/c/intersect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
