ArrayAppend()
Appends an array element to an array.
ArrayAppend( array=array, value=any, merge=boolean );
Returns: Boolean
| Argument | Description |
|---|---|
|
array
array,
required
|
edit
The array to which the element should be appended. |
|
value
any,
required
|
edit
The element to append. Can be any type. Alias: object, obj |
|
merge
boolean,
optional
|
edit
This argument only applies when the value is an array. If set to true appends array elements individually to the source array. If false (default) the complete array is added as one element at the end, in the source array. |
Examples
editnumbers = [ 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 ]
See also
- Arrays
- array.append()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)