ArrayInsertAt

Description

Inserts data in an array at an index position. 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.

Category

Array functions

Syntax


ArrayInsertAt(array, position, value) 

See also

ArrayDeleteAt

Parameters

Parameter
Description
array
Name of an array in which to insert data
position
The index position in an array at which to insert the data specified in value
value
The value of the data 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>



Banner.Novgorod.Ru