Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2Farraycontains.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2Farraycontains.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `arrayContains`

## Description

Returns `true` if an array includes the specified element, or `false` if it does not.

* This function is the mirror version of [inArray](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/array/inArray/.md).
* Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `arrayContains` supports<!-- --> [two notations](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
arrayContains(array: array<T>, element: T): bool
```

```
(array: array<T>).arrayContains(element: T): bool
```

## Arguments

| Name      | Type       | Required | Description                           |
| --------- | ---------- | -------- | ------------------------------------- |
| `array`   | `array<T>` | **true** | The array to search                   |
| `element` | `T`        | **true** | The element to check for in the array |

## Example

**Use case: Check if a client IP is present in a block list.**

Suppose you have a firewall log that records blocked IPs. Consider the following input:

```
{

    "action": "BLOCK",

    "client_ip": "134.56.32.98",

    "blocked_ips": [

        "134.56.32.91",

        "134.56.32.93",

        "134.56.32.90",

        "134.56.32.105"

    ]

}
```

By checking whether `client_ip` is contained in `blocked_ips`, you can determine if the request came from a blocked address.

### Example query

* Function notation
* Method notation

```
create is_blocked_ip from arrayContains(blocked_ips, client_ip)
```

```
create is_blocked_ip from blocked_ips.arrayContains(client_ip)
```

### Example output

The result will include a new field `is_blocked_ip` with a boolean value:

```
{

    "action": "BLOCK",

    "client_ip": "134.56.32.98",

    "blocked_ips": [

        "134.56.32.91",

        "134.56.32.93",

        "134.56.32.90",

        "134.56.32.105"

    ],

    "is_blocked_ip": false

}
```
