arrayAppend

Description

Appends an array element to an array.

Categories

Related

History

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

Syntax

ArrayAppend(array, value)

Attributes

AttributeDescriptionRequiredDefault
arrayName of an array
valueValue to add at end of array

Returns

True, on successful completion.

Example

<h3>ArrayAppend Example</h3> 
<cfquery name = "GetEmployeeNames" datasource = "cfdocexamples"> 
    SELECT FirstName, LastName FROM Employees 
</cfquery> 
<!--- Create an array> ---> 
<cfset myArray = ArrayNew(1)> 
<!--- Set element one to show where we are. ---> 
<cfset myArray[1] = "Test Value"> 
<!--- Loop through the query; append these names successively to the last  
    element. ---> 
<cfloop query = "GetEmployeeNames"> 
    <cfoutput>#ArrayAppend(myArray, "#FirstName# #LastName#")# 
    </cfoutput>, Array was appended<br> 
</cfloop> 
<!--- Show the resulting array as a list. ---> 
<cfset myList = ArrayToList(myArray, ",")> 
<!--- Output the array as a list. ---> 
<cfoutput> 
    The contents of the array are as follows:</p> 
    #myList#</p> 
</cfoutput>