# `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://coralogix.com/docs/dataprime/language-reference/functions-reference/array/inArray/index.md).
- Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `arrayContains` supports [two notations](https://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

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

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

## Arguments

| Name    | Type  | Required | Description                           |
| ------- | ----- | -------- | ------------------------------------- |
| array   | array | **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:

```json
{
    "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

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

```dataprime
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:

```json
{
    "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
}
```
