---
name: "arrayIntersect"
type: command
status: ok
groups: ["Arrays"]
arma3_since: "1.48"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/arrayIntersect
revid: 377192
updated: 2026-01-01T10:54:34Z
---

# arrayIntersect

*Command · Arrays · Arma 3 v1.48*

## Description

Intersects two arrays returning an array of unique common elements, avoiding [nil](../commands/nil.md) values.
Using the same array as both parameters will return unique elements of that array.
Intersects only the first dimension of said arrays.

> [!NOTE]
> From Arma 3 v 2.14 the order of the intersected elements would follow 'array1' order

## Syntax

```sqf
array1 arrayIntersect array2
```

**Parameters:**

- `array1`: [Array](../topics/Array.md) of [Anything](../topics/Anything.md)
- `array2`: [Array](../topics/Array.md) of [Anything](../topics/Anything.md)

**Returns:** [Array](../topics/Array.md) of [Anything](../topics/Anything.md)

## Examples

### Example 1

```sqf
_arr1 = [1,2,3,4,5,2,3,4];
_arr2 = [4,5,6,1,2,3,5,6];
hint str (_arr1 arrayIntersect _arr2); // [4,5,1,2,3]
```

### Example 2

```sqf
_arr = [1,2,3,1,2,3,1,2,3,4,5];
hint str (_arr arrayIntersect _arr); // [1,2,3,4,5]
```

### Example 3

Remove [nil](../commands/nil.md)s:

```sqf
hint str ([1,2,nil,3] arrayIntersect [1,2,nil,3]); // [1,2,3]
```

### Example 4

Also works with array elements which are [equal](../commands/isEqualTo.md):

```sqf
hint str ([[1],[2],[3]] arrayIntersect [[2],[3],[4]]); // [[2],[3]]
```

### Example 5

This command is case-sensitive:

```sqf
["cAse"] arrayIntersect ["cAse"]; // ["cAse"]
["cAse"] arrayIntersect ["casE"]; // []
```

## See also

[append](../commands/append.md) · [set](../commands/set.md) · [pushBack](../commands/pushBack.md) · [pushBackUnique](../commands/pushBackUnique.md) · [apply](../commands/apply.md) · [select](../commands/select.md) · [resize](../commands/resize.md) · [reverse](../commands/reverse.md) · [count](../commands/count.md) · [find](../commands/find.md) · [in](../commands/in.md) · [forEach](../commands/forEach.md) · [deleteAt](../commands/deleteAt.md) · [deleteRange](../commands/deleteRange.md) · [sort](../commands/sort.md) · [param](../commands/param.md) · [params](../commands/params.md) · [toArray](../commands/toArray.md) · [toString](../commands/toString.md) · [splitString](../commands/splitString.md) · [joinString](../commands/joinString.md) · [BIS_fnc_arrayPushStack](../functions/BIS_fnc_arrayPushStack.md) · [BIS_fnc_arrayPush](../functions/BIS_fnc_arrayPush.md)

## Community notes

**Hypoxic125** — 2024-05-26

Selectively filter out elements from _arrayA based on _arrayB.
- Designed to remove the first occurrence of each element found in _arrayB from _arrayA.
- Useful in removing elements where duplicates may exist.

```sqf
private _arrayA = [1, 2, 3, 2, 4, 5, 4];
private _arrayB = [2, 2, 4];

{
    private _index = _arrayA find _x;
    if (_index != -1) then
    {
        _arrayA deleteAt _index;
    };
} forEach _arrayB;

_arrayA; // is now [1, 3, 5, 4]
```

<sub>Source: [BI Community Wiki — arrayIntersect](https://community.bistudio.com/wiki/arrayIntersect) (revision 377192).</sub>
