# ListToArray

Converts a delimited list to an array

## Method Signature

```
ListToArray(list=[string], delimiter=[string], includeEmptyFields=[boolean], multiCharacterDelimiter=[boolean])
```

### Arguments

| Argument                  | Type      | Required | Description                                                    | Default |
| ------------------------- | --------- | -------- | -------------------------------------------------------------- | ------- |
| `list`                    | `string`  | `true`   | string list to filter entries from                             |         |
| `delimiter`               | `string`  | `false`  | string the list delimiter                                      | `,`     |
| `includeEmptyFields`      | `boolean` | `false`  | boolean whether to include empty fields in the returned result | `false` |
| `multiCharacterDelimiter` | `boolean` | `false`  | boolean whether the delimiter is multi-character               | `false` |

## Examples

### Simple example for listToArray function

Uses the listToArray() function to retrieve a list as an array

[Run Example](https://try.boxlang.io/?code=eJzLySwuUbBVUCpKTdFJL0pNzdPJL0rMS09VsuZKTy1xLCpKrARK5wBVheSDeRpgjoKmNVdxfm6qV7C%2FH1AeRAWnFmUm5mRWpWoowHUCVZUXZZak%2BpeWFJSWaCjAtQAlAOB7KJE%3D)

```java
list = "red,green,orange";
getArray = listToArray( list );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

Result: \["red", "green", "orange"]

### Example for listToArray function with delimiter

Uses the listToArray() function with a semicolon delimiter to retrieve a list as an array

[Run Example](https://try.boxlang.io/?code=eJzLySwuUbBVUErKr8hJzEu3LsgosM5KLEu0Li7MUbLmSk8tcSwqSqwEKskBqgzJB%2FM0wBwdBSVrJQVNa67i%2FNxUr2B%2FP6AiEBWcWpSZmJNZlaqhANcOVFVelFmS6l9aUlBaoqEA16JpDQAl4isI)

```java
list = "boxlang;php;java;sql";
getArray = listToArray( list, ";" );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

Result: \["boxlang", "php", "java", "sql"]

### Example for listToArray function with includeEmptyFields

If includeEmptyFields is true, empty value add in array elements

[Run Example](https://try.boxlang.io/?code=eJzLySwuUbBVUErKr8hJzEu3LsgosLbOSixLtC4uzFGy5kpPLXEsKkqsBKrJASoNyQfzNMAcHQUlayUdhZKi0lQFTWuu4vzcVK9gfz%2BgUhAVnFqUmZiTWZWqoQA3BKiqvCizJNW%2FtKSgtERDAa4FKAEAhEctWQ%3D%3D)

```java
list = "boxlang;php;;java;sql";
getArray = listToArray( list, ";", true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

Result: \["boxlang", "php", " " , "java", "sql"]

### Example for listToArray function with multiCharacterDelimiter

Uses the listToArray() function to retrieve a list as an array with multiCharacterDelimiter

[Run Example](https://try.boxlang.io/?code=eJw9jDEOwjAMRfeewsoUJN%2Bg6sDKQIdygQhcCDIk2A6oKIcndOj09fXf%2BxzVYAB3TnyZi8b0xHzLWI3U8B7eAau%2B2PXdlWwvEpYGc3NOaW1%2BLQgOq0OYAyshmBSCXd9petBhGo9N%2BcdEEgPHL3nYzhr1kWg0FsvFPGxKG343TDPk)

```java
list = "boxlang,php,|test,java,|sql";
getArray = listToArray( list, ",|", false, true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

Result: \["boxlang,php", "test,java", "sql"]

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJzLySwuUbBVUCpKTdFJL0pNzdPJL0rMS09VsuZKTy1xLCpKrARK5wBVheSDeRpgjoKmNVdxfm6qV7C%2FH1AeRAWnFmUm5mRWpWoowHUCVZUXZZak%2BpeWFJSWaCjAtQAlAOB7KJE%3D)

```java
list = "red,green,orange";
getArray = listToArray( list );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

[Run Example](https://try.boxlang.io/?code=eJzLySwuUbBVUErOz0lJKy3OzM%2BzLsgosM5KLEu0Li7MUbLmSk8tcSwqSqwEqsoBKg7JB%2FM0wBwdBSVrJQVNa67i%2FNxUr2B%2FP6AiEBWcWpSZmJNZlaqhANcOVFVelFmS6l9aUlBaoqEA1wKUAAD5Lyxd)

```java
list = "boxlang;php;java;sql";
getArray = listToArray( list, ";" );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

[Run Example](https://try.boxlang.io/?code=eJw9jDEOwjAMRfeewsoUpN7AYmBloEO5QFRcMDIkOA4ITl%2FTodPX03%2F%2FC1eDPYQpy2VulfMTy60g3tM7YX1JwO5KdlBNX9fE7XNeKa7QQ8DQg2kj2GFX84OO43By9R8jKSfhH0XYTtz6KBsNzUqzCNvEiwU1ni6k)

```java
list = "boxlang;php;;java;sql";
getArray = listToArray( list, ";", true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

[Run Example](https://try.boxlang.io/?code=eJw9jDEOwjAMRfeewsoUJN%2Bg6sDKQIdygQhcCDIk2A6oKIcndOj09fXf%2BxzVYAB3TnyZi8b0xHzLWI3U8B7eAau%2B2PXdlWwvEpYGc3NOaW1%2BLQgOq0OYAyshmBSCXd9petBhGo9N%2BcdEEgPHL3nYzhr1kWg0FsvFPGxKG343TDPk)

```java
list = "boxlang,php,|test,java,|sql";
getArray = listToArray( list, ",|", false, true );
someJSON = JSONSerialize( getArray );
writeOutput( someJSON );

```

## Related

* [GetToken](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/gettoken)
* [ListAppend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listappend)
* [ListAvg](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listavg)
* [ListChangeDelims](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listchangedelims)
* [ListCompact](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listcompact)
* [ListContains](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listcontains)
* [ListContainsNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listcontainsnocase)
* [ListDeleteAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listdeleteat)
* [ListEach](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listeach)
* [ListEvery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listevery)
* [ListFilter](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfilter)
* [ListFind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfind)
* [ListFindNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfindnocase)
* [ListFirst](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfirst)
* [ListGetAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listgetat)
* [ListGetEndings](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listgetendings)
* [ListIndexExists](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listindexexists)
* [ListInsertAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listinsertat)
* [ListItemTrim](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listitemtrim)
* [ListLast](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listlast)
* [ListLen](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listlen)
* [ListMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listmap)
* [ListNone](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listnone)
* [ListPrepend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listprepend)
* [ListQualify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listqualify)
* [ListReduceRight](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listreduceright)
* [ListRemoveDuplicates](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listremoveduplicates)
* [ListRest](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listrest)
* [ListSetAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listsetat)
* [ListSome](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listsome)
* [ListSort](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listsort)
* [ListTrim](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listtrim)
* [ListValueCount](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listvaluecount)
* [ListValueCountNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listvaluecountnocase)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listtoarray.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
