Name
ArrayAppend
Synopsis
ArrayAppend(array, value
)
Appends an element to the end of an array. Upon successful
completion, ArrayAppend( )
returns a value of
TRUE
. Here’s an example of appending a new
element to a one-dimensional array:
<CFSET Grades = ArrayNew(1)> <CFSET Grades[1] = 95> <CFSET Grades[2] = 93> <CFSET Grades[3] = 87> <CFSET Grades[4] = 100> <CFSET Grades[5] = 74> <B>Original Array:</B><BR> <CFLOOP INDEX="Element" FROM="1" TO="#ArrayLen(Grades)#"> <CFOUTPUT>Grade #Element#: #Grades[Element]#<BR></CFOUTPUT> </CFLOOP> <P>Append the value 66 to the array:<BR> <CFSET ArrayAppend(Grades, "66")> <P><B>New Array:</B><BR> <CFLOOP INDEX="Element" FROM="1" TO="#ArrayLen(Grades)#"> <CFOUTPUT>Grade #Element#: #Grades[Element]#<BR></CFOUTPUT> </CFLOOP>
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.