User Guide

ArrayInsertAt 473
ArrayInsertAt
Description
Inserts a value into an array. Array elements whose indexes are equal to or greater than the new
position are incremented by one. The array length increases by one.
Returns
True, on successful completion.
Category
Array functions
Function syntax
ArrayInsertAt(array, position, value)
See also
ArrayDeleteAt;
“Functions for XML object management” in Chapter 35, “Using XML and
WDDX,” in ColdFusion MX Developer’s Guide
History
ColdFusion MX:
Changed behavior: this function can be used on XML objects.
Changed thrown exceptions: this function can throw the InvalidArrayIndexException error.
Parameters
Usage
To apply the ArrayInsert() function to a multidimensional array, you must specify all but the
last index in the
array parameter. For example, the following code inserts an element at
myarray[2][4]:
<cfset ArrayInsertAt(myarray[2], 4, “test”)>
Throws
If this function attempts to insert 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>ArrayInsertAt Example</h3><p>
<!--- create a new array --->
<cfset DaysArray = ArrayNew(1)>
<!--- populate an element or two --->
Parameter Description
array Name of an array
position Index position at which to insert value
value Value to insert