Appends an element to the end of an array.
arrayAppend(array, value [, merge])
returns boolean
someArray.append(value [, merge])
Name | Type | Required | Default | Description |
---|---|---|---|---|
array | array | Yes | The array to which the element should be appended. | |
value | any | Yes | The element to append. Can be any type. | |
merge | boolean | No | NO | CF10+ When true appends array elements individually to the specified array. When false (default), the new array is appended as a single element. |
Uses the arrayAppend function to append a value to the end of the array
someArray = [1,2,3];
arrayAppend(someArray, 4);
writeOutput(serializeJSON(someArray));
CF11+ Lucee4.5+ Invoking the append function on an array is the same as running arrayAppend.
someArray = [1,2,3];
someArray.append(4);
writeOutput(serializeJSON(someArray));
CF10+ You can merge two arrays when third parameter is set to true.
someArray = [1,2,3];
ArrayAppend(someArray,[4,5,6],true);
writeDump(serializeJSON(someArray));