> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayappend.md).

# ArrayAppend

Append a value to an array

## Method Signature

```
ArrayAppend(array=[modifiableArray], value=[any], merge=[boolean])
```

### Arguments

| Argument | Type              | Required | Description                                                                                                                                                          | Default |
| -------- | ----------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `array`  | `modifiableArray` | `true`   | The array to which the element should be appended.                                                                                                                   |         |
| `value`  | `any`             | `true`   | The element to append. Can be any type.                                                                                                                              |         |
| `merge`  | `boolean`         | `false`  | <p>If true, the value is assumed to be an array and the elements of the array are appended to the array. If false, the value is<br>appended as a single element.</p> | `false` |

## Examples

### Append a value to an array

Uses the arrayAppend function to append a value to the end of the array

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

```java
someArray = [ 
	1,
	2,
	3
];
arrayAppend( someArray, 4 );
writeOutput( JSONSerialize( someArray ) );

```

Result: \[1,2,3,4]

### Append a value to an array using the Array member function

Invoking the append function on an array is the same as running arrayAppend.

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

```java
someArray = [ 
	1,
	2,
	3
];
someArray.append( 4 );
writeOutput( JSONSerialize( someArray ) );

```

Result: \[1,2,3,4]

### Append more than one item

You can merge two arrays when third parameter is set to true.

[Run Example](https://try.boxlang.io/?code=eJwrzs9NdSwqSqxUsFWIVuDiNNTh4jQCYmOuWGsusIRjQUFqXoqGQjFMpY5CNBenCVCNKRCbccXqKJQUlaYqaFpzlRdllqS6lOYWaCh4Bfv7BacWZSbmZFalImlW0AQpBACAdyFm)

```java
someArray = [ 
	1,
	2,
	3
];
ArrayAppend( someArray, [
	4,
	5,
	6
], true );
writeDump( JSONSerialize( someArray ) );

```

Result: \[1,2,3,4,5,6]

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJy9kL0KwkAQhOvsU0ypsBDyc0kgWASs9QHCFYpX3nlc7grf3hVBr4iCjcU0s7M7H%2BuSPZuwYIcZVFRMRS1qRC3pkaYQTrfJe%2BMuG7hnlqGwHWmfrH95YqAscUzRp7jIrYpRMxpG%2B4hrcu%2BelRp7DeaQJ5RMOlEvGj6D5Hs%2FIc1QjI7RMwbof%2FAxYkhmjZK%2BfC6DpDtjNG%2Bu)

```java
numbers = [ 
	1,
	2,
	3,
	4
];
ArrayAppend( numbers, 5 );
Dump( numbers ); // Outputs [ 1, 2, 3, 4, 5 ]
numbers = [
	1,
	2,
	3,
	4
];
moreNumbers = [
	5,
	6,
	7,
	8
];
ArrayAppend( numbers, moreNumbers );
Dump( numbers ); // Outputs [ 1, 2, 3, 4, [ 5, 6, 7, 8 ] ]
numbers = [
	1,
	2,
	3,
	4
];
moreNumbers = [
	5,
	6,
	7,
	8
];
ArrayAppend( numbers, moreNumbers, true );
Dump( numbers );
 // Outputs [ 1, 2, 3, 4, 5, 6, 7, 8 ]

```

## Related

* [ArrayAvg](/boxlang-language/reference/built-in-functions/array/arrayavg.md)
* [ArrayChunk](/boxlang-language/reference/built-in-functions/array/arraychunk.md)
* [ArrayClear](/boxlang-language/reference/built-in-functions/array/arrayclear.md)
* [ArrayContains](/boxlang-language/reference/built-in-functions/array/arraycontains.md)
* [ArrayContainsNoCase](/boxlang-language/reference/built-in-functions/array/arraycontainsnocase.md)
* [ArrayDelete](/boxlang-language/reference/built-in-functions/array/arraydelete.md)
* [ArrayDeleteAt](/boxlang-language/reference/built-in-functions/array/arraydeleteat.md)
* [ArrayDeleteNoCase](/boxlang-language/reference/built-in-functions/array/arraydeletenocase.md)
* [ArrayEach](/boxlang-language/reference/built-in-functions/array/arrayeach.md)
* [ArrayEvery](/boxlang-language/reference/built-in-functions/array/arrayevery.md)
* [ArrayFilter](/boxlang-language/reference/built-in-functions/array/arrayfilter.md)
* [ArrayFind](/boxlang-language/reference/built-in-functions/array/arrayfind.md)
* [ArrayFindAll](/boxlang-language/reference/built-in-functions/array/arrayfindall.md)
* [ArrayFindAllNoCase](/boxlang-language/reference/built-in-functions/array/arrayfindallnocase.md)
* [ArrayFindFirst](/boxlang-language/reference/built-in-functions/array/arrayfindfirst.md)
* [ArrayFindNoCase](/boxlang-language/reference/built-in-functions/array/arrayfindnocase.md)
* [ArrayFirst](/boxlang-language/reference/built-in-functions/array/arrayfirst.md)
* [ArrayFlatMap](/boxlang-language/reference/built-in-functions/array/arrayflatmap.md)
* [ArrayFlatten](/boxlang-language/reference/built-in-functions/array/arrayflatten.md)
* [ArrayGetMetadata](/boxlang-language/reference/built-in-functions/array/arraygetmetadata.md)
* [ArrayGroupBy](/boxlang-language/reference/built-in-functions/array/arraygroupby.md)
* [ArrayIndexExists](/boxlang-language/reference/built-in-functions/array/arrayindexexists.md)
* [ArrayInsertAt](/boxlang-language/reference/built-in-functions/array/arrayinsertat.md)
* [ArrayIsDefined](/boxlang-language/reference/built-in-functions/array/arrayisdefined.md)
* [ArrayLast](/boxlang-language/reference/built-in-functions/array/arraylast.md)
* [ArrayMap](/boxlang-language/reference/built-in-functions/array/arraymap.md)
* [ArrayMax](/boxlang-language/reference/built-in-functions/array/arraymax.md)
* [ArrayMedian](/boxlang-language/reference/built-in-functions/array/arraymedian.md)
* [ArrayMerge](/boxlang-language/reference/built-in-functions/array/arraymerge.md)
* [ArrayMid](/boxlang-language/reference/built-in-functions/array/arraymid.md)
* [ArrayMin](/boxlang-language/reference/built-in-functions/array/arraymin.md)
* [ArrayNew](/boxlang-language/reference/built-in-functions/array/arraynew.md)
* [ArrayNone](/boxlang-language/reference/built-in-functions/array/arraynone.md)
* [ArrayPop](/boxlang-language/reference/built-in-functions/array/arraypop.md)
* [ArrayPrepend](/boxlang-language/reference/built-in-functions/array/arrayprepend.md)
* [ArrayPush](/boxlang-language/reference/built-in-functions/array/arraypush.md)
* [ArrayRange](/boxlang-language/reference/built-in-functions/array/arrayrange.md)
* [ArrayReduce](/boxlang-language/reference/built-in-functions/array/arrayreduce.md)
* [ArrayReduceRight](/boxlang-language/reference/built-in-functions/array/arrayreduceright.md)
* [ArrayReject](/boxlang-language/reference/built-in-functions/array/arrayreject.md)
* [ArrayResize](/boxlang-language/reference/built-in-functions/array/arrayresize.md)
* [ArrayReverse](/boxlang-language/reference/built-in-functions/array/arrayreverse.md)
* [ArraySet](/boxlang-language/reference/built-in-functions/array/arrayset.md)
* [ArrayShift](/boxlang-language/reference/built-in-functions/array/arrayshift.md)
* [ArraySlice](/boxlang-language/reference/built-in-functions/array/arrayslice.md)
* [ArraySome](/boxlang-language/reference/built-in-functions/array/arraysome.md)
* [ArraySort](/boxlang-language/reference/built-in-functions/array/arraysort.md)
* [ArraySplice](/boxlang-language/reference/built-in-functions/array/arraysplice.md)
* [ArraySum](/boxlang-language/reference/built-in-functions/array/arraysum.md)
* [ArraySwap](/boxlang-language/reference/built-in-functions/array/arrayswap.md)
* [ArrayToList](/boxlang-language/reference/built-in-functions/array/arraytolist.md)
* [ArrayToStruct](/boxlang-language/reference/built-in-functions/array/arraytostruct.md)
* [ArrayTranspose](/boxlang-language/reference/built-in-functions/array/arraytranspose.md)
* [ArrayUnique](/boxlang-language/reference/built-in-functions/array/arrayunique.md)
* [ArrayUnshift](/boxlang-language/reference/built-in-functions/array/arrayunshift.md)
* [ArrayZip](/boxlang-language/reference/built-in-functions/array/arrayzip.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayappend.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
