Description

Appends an array element to an array.  Concatenates arrays when the merge argument is set to true and the value argument is an array.

Returns

True, on successful completion.

Category

Function syntax

ArrayAppend(array, value [,merge])

See also

ArrayPrependAdding elements to an array in Basic array techniques in the Developing ColdFusion Applications

History

Coldfusion 10: Added the merge argument

ColdFusion MX: Changed behavior: this function can be used on XML objects.

Parameters

Parameter

Description

array

Name of an array

value

Value to add at end of array

merge

If set to true, and value parameter is an array, 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. If value is not an array this argument is ignored.

Example

<cfscript>
       myArray=[1,2,3,4,5];
       ArrayAppend(myArray,6,"true");
       writeoutput(serializeJSON(myArray)); //adds the value 6 to myArray
</cfscript>

Output

[1,2,3,4,5,6]

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy