Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Farray%2FinArray.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%2FinArray.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `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://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/array/arraycontains/.md).
* Supported element types include `string`, `bool`, `number`, `interval`, `timestamp`, `regexp`, and `enum`.

## Syntax

Like many functions in DataPrime, `inArray` 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

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

```
(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<T>` | **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:

```
{

    "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

* Function notation
* Method notation

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

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

```
{

    "client_ip": "192.168.1.105",

    "is_blocked": true

}
```
