# `inArray`

## Description

Returns `true` if the specified element exists within the array, or `false` if it does not.

- This function is the inverse of [`arrayContains`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/array/arraycontains/index.md).
- Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `inArray` 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
inArray(element: T, array: array<T>): bool
```

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

## Arguments

| Name    | Type  | Required | Description                                                              |
| ------- | ----- | -------- | ------------------------------------------------------------------------ |
| element | T     | **true** | The element to check for in the array                                    |
| array   | array | **true** | The array to search, must contain elements of the same type as `element` |

## Example

**Use case: Check if a client IP appears in a block list**

Suppose you have a log entry with a client IP. Consider the following input:

```json
{
    "client_ip": "192.168.1.105"
}
```

By checking whether the `client_ip` value exists in an array of blocked IP addresses, you can identify whether the request should be blocked.

### Example query

```dataprime
filter inArray(client_ip, ['192.168.1.105', '192.168.1.112', '192.168.1.32'])
```

```dataprime
filter client_ip.inArray(['192.168.1.105', '192.168.1.112', '192.168.1.32'])
```

### Example output

The result will return `true` since `"192.168.1.105"` is included in the array:

```json
{
    "client_ip": "192.168.1.105",
    "is_blocked": true
}
```
