> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xano.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Array

<Tip>
  **NOTE**

  When a filter below refers to the **parent value**, we're talking about the value box that lives immediately above the filter.

  <Frame>
    <img src="https://mintcdn.com/xano-997cb9ee/ClU5W_-qt6GI3QWZ/images/465e2547-image.jpeg?fit=max&auto=format&n=ClU5W_-qt6GI3QWZ&q=85&s=b224df8de804bea26c1c4f7994db2d87" width="633" height="199" data-path="images/465e2547-image.jpeg" />
  </Frame>
</Tip>

```json theme={null}
[
    {
        "name": "Chris"
        },
    {
        "name": "Shawn"
        }
]
```

### append

Adds a new element to the end of the array, and return the updated array

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/_Sd90ZcMa6hsPScv/images/d0228175-image.jpeg?fit=max&auto=format&n=_Sd90ZcMa6hsPScv&q=85&s=3b7900657cdec01b40fb4223387825f6" width="1065" height="333" data-path="images/d0228175-image.jpeg" />
</Frame>

| Parameter    | Purpose                                  | Example    |
| ------------ | ---------------------------------------- | ---------- |
| parent value | The original array you'd like to modify  | \[1,2,3,4] |
| value        | The value to add to the end of the array | 5          |

| Example                                                                                            | Result                                                                                                                  |
| -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| parent value: `[1, 2, 3, 4]`<br />value: 5                                                         | `[1, 2, 3, 4, 5]`                                                                                                       |
| parent value: `["Think Visually", "Build Confidently"]` value:<br />"Deploy Securely"              | `["Think Visually, Build Confidently, "Deploy Securely"]`                                                               |
| parent value:<br />`[    {        "name": "Chris"        },    {        "name": "Shawn"        }]` |                                                                                                                         |
| <br />value:<br />`{        "name": "Cameron"        }`                                            | `[    {        "name": "Chris"        },    {        "name": "Shawn"        },    {        "name": "Cameron"        }]` |

***

### count

Returns the number of items in an array

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/nsvdyKK4Dg7VUAZs/images/8d32729f-image.jpeg?fit=max&auto=format&n=nsvdyKK4Dg7VUAZs&q=85&s=b332881d78d9ead7718025b9f5977a7c" width="1071" height="206" data-path="images/8d32729f-image.jpeg" />
</Frame>

| Paremeter    | Purpose            | Example                                         |
| ------------ | ------------------ | ----------------------------------------------- |
| parent value | The array to count | `[1, 2, 3, 4, 5]`                               |
|              |                    | `[    {"name": "Chris"},    {"name": "Shawn"}]` |

| Example                                         | Output |   |                   |   |
| ----------------------------------------------- | ------ | - | ----------------- | - |
| `[    {"name": "Chris"},    {"name": "Shawn"}]` | 2      |   | `[1, 2, 3, 4, 5]` | 5 |

***

### diff / diff\_assoc

### intsersect / intersect\_assoc

These filters are used to compare arrays.

* **diff** is used to show values from the first array that **are not** in the second array

* **intersect** is used to show values from the first array that **are** in the second array

Use the basic filter for value arrays, and the **\_assoc** version for arrays of objects.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/kBkSb_XZ48XRxJA_/images/a8d86c75-image.jpeg?fit=max&auto=format&n=kBkSb_XZ48XRxJA_&q=85&s=4cd688bbeffe3d3d19c1fb283ee941b0" width="1056" height="943" data-path="images/a8d86c75-image.jpeg" />
</Frame>

| Parameter    | Purpose                     | Example                                         |
| ------------ | --------------------------- | ----------------------------------------------- |
| parent value | The first array to compare  | `[1, 2, 3, 4, 5]`                               |
|              |                             | `[    {"name": "Chris"},    {"name": "Shawn"}]` |
| value        | The second array to compare | Same as above                                   |

| Example                                                                                                                                                                               | Output                                          |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| Using **diff:**<br />parent value: `[1,2,3,4,5]` value: `[3,4,5,6,7]`                                                                                                                 | `[1, 2]`                                        |
| Using **diff\_assoc:**<br />parent value:<br />`[    {"name": "Chris"},    {"name": "Shawn"},    {"name": "Cameron"}]<br/>`value:`<br/>[    {"name": "Chris"},    {"name": "Shawn"}]` | `[    {"name":"Cameron"}]`                      |
| Using **intersect:**<br />parent value: `[1,2,3,4,5]`<br />value: `[3,4,5,6,7]`                                                                                                       | `[3, 4, 5]`                                     |
| Using **intersect\_assoc:** parent value:`[    {"name": "Chris"},    {"name": "Shawn"}]`value:`[    {"name": "Chris"},    {"name": "Shawn"},    {"name": "Cameron"}]`                 | `[    {"name": "Chris"},    {"name": "Shawn"}]` |

***

### filter\_empty

Returns a new srray with only entries that are not empty.

An **empty** value can be `[]`, `{}`, `0`, `null`, `""`, or `false`.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/o7zunZFYmjx8RZ8N/images/f15245fe-image.jpeg?fit=max&auto=format&n=o7zunZFYmjx8RZ8N&q=85&s=22cbeee8e6a9f2b97048064e5df861ea" width="1065" height="310" data-path="images/f15245fe-image.jpeg" />
</Frame>

| Parameter    | Purpose                                                                                                       | Example                                              |
| ------------ | ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| parent value | The array to filter                                                                                           | `[1, 0, 2, 0, 3]`                                    |
|              |                                                                                                               | `[    {"name":"Chris"},    {},    {"name":"Shawn"}]` |
| path         | When filtering arrays of objects, you can specify a path to optionally use a specific key to judge emptiness. |                                                      |

| Example                                              | Output                                        |
| ---------------------------------------------------- | --------------------------------------------- |
| `[    {"name":"Chris"},    {},    {"name":"Shawn"}]` | `[    {"name":"Chris"},    {"name":"Shawn"}]` |
| `[1, 0, 2, 0, 3]`                                    | `[1, 2, 3]`                                   |

***

### first

Get the first entry of an Array.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/RVHCrB1RJjFkWEmQ/images/11766009-image.jpeg?fit=max&auto=format&n=RVHCrB1RJjFkWEmQ&q=85&s=8dfacd709004ad1a8c9d9164845d81c4" width="1072" height="214" data-path="images/11766009-image.jpeg" />
</Frame>

| Parameter    | Purpose                                    | Example                                       |
| ------------ | ------------------------------------------ | --------------------------------------------- |
| parent value | The array to retrieve the first entry from | `[1, 2, 3]`                                   |
|              |                                            | `[    {"name":"Chris"},    {"name":"Shawn"}]` |

| Example                                       | Output             |
| --------------------------------------------- | ------------------ |
| `[1, 2, 3]`                                   | 1                  |
| `[    {"name":"Chris"},    {"name":"Shawn"}]` | `{"name":"Chris"}` |

***

### filter\_empty\_array

### filter\_empty\_object

### filter\_empty\_text

### filter\_false

### filter\_null

### filter\_zero

These filters are designed to remove the corresponding values from an object or an array. Useful in scenarios where something is sending data to your APIs that you don't have full control over, such as a frontend platform that always sends empty strings or null values.

| Parameter    | Purpose                       |
| ------------ | ----------------------------- |
| parent value | The array or object to target |

| Example                                                                                                                      | Output                                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `{        "title": "",        "name": false,        "width": 0,        "items": [],        "data": {},        "info": null}` | **filter\_empty\_array<br />**`{        "title": "",        "name": false,        "width": 0,        "data": {},        "info": null}`   |
| `{        "title": "",        "name": false,        "width": 0,        "items": [],        "data": {},        "info": null}` | **filter\_empty\_object<br />**`{        "title": "",        "name": false,        "width": 0,        "items": [],        "info": null}` |
| `{        "title": "",        "name": false,        "width": 0,        "items": [],        "data": {},        "info": null}` | **filter\_empty\_text<br />**`{        "name": false,        "width": 0,        "items": [],        "data": {},        "info": null}`    |
| `{        "title": "",        "name": false,        "width": 0,        "items": [],        "data": {},        "info": null}` | **filter\_false<br />**`{        "title": "",        "width": 0,        "items": [],        "data": {},        "info": null}`            |
| `{        "title": "",        "name": false,        "width": 0,        "items": [],        "data": {},        "info": null}` | **filter\_null<br />**`{        "title": "",        "name": false,        "width": 0,        "items": [],        "data": {}}`            |
| `{        "title": "",        "name": false,        "width": 0,        "items": [],        "data": {},        "info": null}` | **filter\_zero<br />**`{        "title": "",        "name": false,        "items": [],        "data": {},        "info": null}`          |

***

### flatten

Flattens a multi-level array into a single-level array.

| Parameter    | Purpose              | Example                                 |
| ------------ | -------------------- | --------------------------------------- |
| parent value | The array to flatten | `[  [1, 2, 3],  [4, 5, 6],  [7, 8, 9]]` |

| Example                                                                                                                                                                                                                   | Output                                                                                                                                                                                                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `[  [1, 2, 3],  [4, 5, 6],  [7, 8, 9]]`                                                                                                                                                                                   | `[1, 2, 3, 4, 5, 6, 7, 8, 9]`                                                                                                                                                                                                                                    |
| `[  {    id: 1,    name: "John",    pets: [      { type: "dog", name: "Rex" },      { type: "cat", name: "Whiskers" }    ]  },  {    id: 2,    name: "Sarah",    pets: [      { type: "bird", name: "Tweety" }    ]  }]]` | `[  {    ownerId: 1,    ownerName: "John",    petType: "dog",    petName: "Rex"  },  {    ownerId: 1,    ownerName: "John",    petType: "cat",    petName: "Whiskers"  },  {    ownerId: 2,    ownerName: "Sarah",    petType: "bird",    petName: "Tweety"  }]` |

***

### join

Converts an array into a text string by *joining* each value and using a separator.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/pz6e9Ndbn8i3u8Zz/images/6de8d76c-image.jpeg?fit=max&auto=format&n=pz6e9Ndbn8i3u8Zz&q=85&s=25714f46a43765ba28e5c91da9c683fc" width="1074" height="232" data-path="images/6de8d76c-image.jpeg" />
</Frame>

| Parameter          | Purpose                                                         | Example                                             |
| ------------------ | --------------------------------------------------------------- | --------------------------------------------------- |
| parent value       | The array to join                                               | \["a", "b", "c"]                                    |
| separator optional | The character or characters to place in between each array item | Can be any text value, or even a single empty space |

| Example                                       | Output  |
| --------------------------------------------- | ------- |
| parent value: `["a", "b", "c"]` separator: \_ | `a_b_c` |
| parent value: \[1, 2, 3, 4, 5] separator:     | `12345` |

***

### last

Get the last entry of an Array.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/o7zunZFYmjx8RZ8N/images/ef196039-image.jpeg?fit=max&auto=format&n=o7zunZFYmjx8RZ8N&q=85&s=f90a6b6b6e2cf8db301dc9edc0c2b0de" width="1069" height="215" data-path="images/ef196039-image.jpeg" />
</Frame>

| Parameter    | Purpose                            | Example      |
| ------------ | ---------------------------------- | ------------ |
| parent value | The array to get the last entry of | \[`1, 2, 3]` |

| Example     | Output |
| ----------- | ------ |
| `[1, 2, 3]` | `3`    |

***

### merge

### merge\_recursive

Merge two arrays or objects together and return the new item.

* Use \*\*merge \*\*to merge single level data.

* Use **merge\_recursive** to merge multi-level data.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/RVHCrB1RJjFkWEmQ/images/0eabcd96-image.jpeg?fit=max&auto=format&n=RVHCrB1RJjFkWEmQ&q=85&s=e6908bae72647b71fafa5c0e7041bb0d" width="1067" height="421" data-path="images/0eabcd96-image.jpeg" />
</Frame>

| Parameter    | Purpose                   | Example    |
| ------------ | ------------------------- | ---------- |
| parent value | The first array to merge  | \[1, 2, 3] |
| value        | The second array to merge | \[4, 5, 6] |

| Example                                                                                                                 | Output                                                       |
| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| using **merge**parent value: `["a", "b", "c"]` value: `["d", "e", "f"]`                                                 | `["a", "b", "c", "d", "e", "f"]`                             |
| using **merge\_recursive**parent value:`{    "a": "test",    "b": ["a","b"]}`value:`{    "c": "hi",    "b": ["c","d"]}` | `{    "a": "test",    "b": ["a","b","c","d"]    "c": "hi",}` |

***

### pop

Pops the last element of the Array off and returns it.

<Warning>
  Please note that Xano's \*\*pop \*\*filter does NOT remove the item from the array.
</Warning>

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/-vy8_DWVOwkWo8Bt/images/8a2ff016-image.jpeg?fit=max&auto=format&n=-vy8_DWVOwkWo8Bt&q=85&s=4c2407efa83c2e3828ca53e8a8f90ad3" width="1071" height="216" data-path="images/8a2ff016-image.jpeg" />
</Frame>

***

### prepend

Push an element on to the beginning of an array

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/rOuOq7qlTNyaIMAW/images/5cc443ab-image.jpeg?fit=max&auto=format&n=rOuOq7qlTNyaIMAW&q=85&s=78db1c1db5e282b96694e9b6b19a69f5" width="1067" height="324" data-path="images/5cc443ab-image.jpeg" />
</Frame>

***

### push

Push an element on to the end of an array

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/tjSJ_pOzk8E0WRhF/images/c2e52228-image.jpeg?fit=max&auto=format&n=tjSJ_pOzk8E0WRhF&q=85&s=3e5d50d6e77fb889c99a60b3d27e13d1" width="1068" height="383" data-path="images/c2e52228-image.jpeg" />
</Frame>

***

### range

Returns array of values between the specified start/stop.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/pz6e9Ndbn8i3u8Zz/images/612f0e43-image.jpeg?fit=max&auto=format&n=pz6e9Ndbn8i3u8Zz&q=85&s=2f605f08018060d6d7b52fae4d11daa6" width="1071" height="212" data-path="images/612f0e43-image.jpeg" />
</Frame>

***

### remove

Remove any elements from the array that match the supplied value and return the new array

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/dC3SQWgPCF_-1qn6/images/2ec6dc31-image.jpeg?fit=max&auto=format&n=dC3SQWgPCF_-1qn6&q=85&s=2463087a87b4319db1f8a2265a0e3c10" width="1069" height="297" data-path="images/2ec6dc31-image.jpeg" />
</Frame>

Use the **path** option to search inside of objects.

Use the **strict** option to determine how precise the filter is (for example, treating 100 and "100" the same)

***

### safe\_array

Always returns an array. Uses the existing value if it is an array or creates an array of one element.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/nsvdyKK4Dg7VUAZs/images/995b08cf-image.jpeg?fit=max&auto=format&n=nsvdyKK4Dg7VUAZs&q=85&s=d5bdd704cedeea6069840290066af236" width="1303" height="465" data-path="images/995b08cf-image.jpeg" />
</Frame>

***

### shift

Shifts the first element off the Array and returns it.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/-vy8_DWVOwkWo8Bt/images/84a0e0c8-image.jpeg?fit=max&auto=format&n=-vy8_DWVOwkWo8Bt&q=85&s=b5518d29ad225be0e9a0310754b3a6a3" width="1074" height="212" data-path="images/84a0e0c8-image.jpeg" />
</Frame>

***

### shuffle

Returns the array in a randomized order

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/dyVYERTquSXdpw_-/images/9e38df91-image.jpeg?fit=max&auto=format&n=dyVYERTquSXdpw_-&q=85&s=25848b307bdb7081258a4f535eebe1ab" width="1306" height="842" data-path="images/9e38df91-image.jpeg" />
</Frame>

***

### slice

Extracts and returns a section of an array

* **offset** - what index should the slice start, starting at 0

* **length** - how many items to slice

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/NAqNmVIgcJlXegps/images/00027478-image.jpeg?fit=max&auto=format&n=NAqNmVIgcJlXegps&q=85&s=fd6f472729ee15329ac7dd8ff6606d07" width="1298" height="899" data-path="images/00027478-image.jpeg" />
</Frame>

***

### sort

Sort an Array of elements with an optional path inside the element, sort type, and ascending/descending. Sort types include:

* **text** - case-sensitive sort for text
* **itext** - case-insensitive sort for text
* **number** - to sort numerically
* **natural** - case-sensitive sort that is alphanumerical and natural to humans
* **inatural** - case-insensitive sort that is alphanumerical and natural to humans

Ascending order is performed with a true boolean. Descending order uses a false boolean.

The example below shows the difference between case-sensitivity sort with text and itext:

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/pz6e9Ndbn8i3u8Zz/images/6dc587c9-image.jpeg?fit=max&auto=format&n=pz6e9Ndbn8i3u8Zz&q=85&s=61e2bb2202d1f3b53bb7fe5a299c8892" width="1072" height="355" data-path="images/6dc587c9-image.jpeg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/dC3SQWgPCF_-1qn6/images/2764cfea-image.jpeg?fit=max&auto=format&n=dC3SQWgPCF_-1qn6&q=85&s=e34ff38996bb434fa5291fb338185296" width="1073" height="361" data-path="images/2764cfea-image.jpeg" />
</Frame>

The example below shows how to use the number sort type:

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/-vy8_DWVOwkWo8Bt/images/895c8aa2-image.jpeg?fit=max&auto=format&n=-vy8_DWVOwkWo8Bt&q=85&s=dc4cddb0845d8184dccef7d39f80b9e3" width="1071" height="356" data-path="images/895c8aa2-image.jpeg" />
</Frame>

The example below shows using the natural sorting option

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/rOuOq7qlTNyaIMAW/images/5eb027a4-image.jpeg?fit=max&auto=format&n=rOuOq7qlTNyaIMAW&q=85&s=26a55f32cb73403555bfafb88a199d58" width="1067" height="399" data-path="images/5eb027a4-image.jpeg" />
</Frame>

***

### unique

Returns unique values of an Array. You can also use this filter with an array of objects by specifying a path to the key you would like to use to judge uniqueness.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/NAqNmVIgcJlXegps/images/075a86b4-image.jpeg?fit=max&auto=format&n=NAqNmVIgcJlXegps&q=85&s=b527f4ec76a7beadad73ede804cf67f7" width="1069" height="290" data-path="images/075a86b4-image.jpeg" />
</Frame>

***

### unshift

Push an element to the beginning of an Array and return the new Array.

<Frame>
  <img src="https://mintcdn.com/xano-997cb9ee/Zmn_DUDgqMkazo6J/images/e2334802-image.jpeg?fit=max&auto=format&n=Zmn_DUDgqMkazo6J&q=85&s=b3f9fc9208b81c7b0707bd0ae70e8aab" width="1070" height="406" data-path="images/e2334802-image.jpeg" />
</Frame>

***

### pick/unpick

These filters are meant to be used when dealing with Object field types and are particularly useful if you are receiving a large object, from a webhook for example, where only a few of those records are required for your workflows. You can also use them with an array of objects by specifying a path to the key you would like to make changes to.

**Pick**: Identify values you would like to keep and the filter will return a new object containing only the values you have selected.

<Frame caption="Example Object">
  <img src="https://mintcdn.com/xano-997cb9ee/o7zunZFYmjx8RZ8N/images/f6874572-image.jpeg?fit=max&auto=format&n=o7zunZFYmjx8RZ8N&q=85&s=44f821ee21271b12ed396ca10ee0de8c" width="938" height="1230" data-path="images/f6874572-image.jpeg" />
</Frame>

<Frame caption="Defining the Keys we want to include in our new object.">
  <img src="https://mintcdn.com/xano-997cb9ee/rOuOq7qlTNyaIMAW/images/5bd553a0-image.jpeg?fit=max&auto=format&n=rOuOq7qlTNyaIMAW&q=85&s=c7b4bed948ddfbf117c9ddfa0927ef0c" width="960" height="744" data-path="images/5bd553a0-image.jpeg" />
</Frame>

<Frame caption="Result">
  <img src="https://mintcdn.com/xano-997cb9ee/_oKnuVg5Nf4VhJM4/images/4ba49334-image.jpeg?fit=max&auto=format&n=_oKnuVg5Nf4VhJM4&q=85&s=d28e0b614e482f5e98fcea1af81d31f7" width="960" height="1344" data-path="images/4ba49334-image.jpeg" />
</Frame>

**Unpick**: Identify values you would like to exclude and the filter will return a new object containing only the fields that weren’t omitted.

<Frame caption="Example Object">
  <img src="https://mintcdn.com/xano-997cb9ee/SGxJ0muPK3um9hNH/images/73396bc4-image.jpeg?fit=max&auto=format&n=SGxJ0muPK3um9hNH&q=85&s=10aeb9e408e87466ea4a464875809068" width="940" height="1230" data-path="images/73396bc4-image.jpeg" />
</Frame>

<Frame caption="Defining the Keys we want to exclude from our new object.">
  <img src="https://mintcdn.com/xano-997cb9ee/_FyaEhYRFYQZinJ0/images/e113424c-image.jpeg?fit=max&auto=format&n=_FyaEhYRFYQZinJ0&q=85&s=5c3da41ac7c9bcb38cb1d62e4a73ce05" width="956" height="674" data-path="images/e113424c-image.jpeg" />
</Frame>

<Frame caption="Result">
  <img src="https://mintcdn.com/xano-997cb9ee/_oKnuVg5Nf4VhJM4/images/4ba49334-image.jpeg?fit=max&auto=format&n=_oKnuVg5Nf4VhJM4&q=85&s=d28e0b614e482f5e98fcea1af81d31f7" width="960" height="1344" data-path="images/4ba49334-image.jpeg" />
</Frame>
