ArrayInsertAt

Inserts data in the specified array at the specified index position. All array elements with indexes greater than the new position are shifted right by one. The length of the array increases by one index.

Returns a Boolean TRUE on successful completion.

See also ArrayDeleteAt.

Syntax

ArrayInsertAt(array, position, value)
array

Name of the array in which you want to insert data.

position

The index position in the specified array where you want to insert the data specified in value.

value

The value of the data you want to insert into the array.

Example

<!--- This example shows ArrayInsertAt --->
<HTML>
<HEAD>
<TITLE>ArrayInsertAt Example</TITLE>
</HEAD>

<BODY>
<H3>ArrayInsertAt Example</H3>

<P>
<!--- create a new array --->
<CFSET DaysArray = ArrayNew(1)>
<!--- populate an element or two --->
<CFSET DaysArray[1] = "Monday">
<CFSET DaysArray[2] = "Tuesday">
<CFSET DaysArray[3] = "Thursday">
<!--- add an element before position 3 --->
<P>Add an element before position 3: 
<CFOUTPUT>#ArrayInsertAt(DaysArray,3,"Wednesday")#</CFOUTPUT>
<P>Now output the array as a list:
<CFOUTPUT>#ArrayToList(DaysArray)#</CFOUTPUT>
<!--- Notice how the array now has four elements, and that
element 3, "Thursday", has now become element four --->
</BODY>
</HTML>

1