User Guide

380 Chapter 3: ColdFusion Functions
ArrayDeleteAt
Description
Deletes an element from an array.
When an element is deleted, ColdFusion recalculates index positions. For example, in an array
that contains the months of the year, deleting the element at position 5 removes the entry for
May. After this, to delete the entry for June, you would delete the element at position 5 (not 6).
Returns
True, on successful completion.
Category
Array functions
Function syntax
ArrayDeleteAt(array, position)
See also
ArrayInsertAt
History
ColdFusion MX:
Changed behavior: this function can be used on XML objects.
Changed thrown exceptions: this function can throw the InvalidArrayIndexException error.
Parameters
Throws
If this function attempts to delete an element at position 0, or specifies a value for position that
is greater than the size of
array, this function throws an InvalidArrayIndexException error.
Example
<h3>ArrayDeleteAt Example</h3><p>
<!--- create an array --->
<cfset DaysArray = ArrayNew(1)>
<!--- populate an element or two --->
<cfset DaysArray[1] = "Monday">
<cfset DaysArray[2] = "Tuesday">
<cfset DaysArray[3] = "Wednesday">
<!--- delete the second element --->
<p>Is the second element gone?:
<cfoutput>#ArrayDeleteAt(DaysArray,2)#</cfoutput>
<!--- the formerly third element, "Wednesday" is second element --->
<p>The second element is now: <cfoutput>#DaysArray[2]#</cfoutput>
Parameter Description
array Name of an array
position Array position