Whatever message this page gives is out now! Go check it out!

ArraySet

Last update:
May 18, 2026

Description

In a one-dimensional array, sets the elements in a specified index range to a value. Useful for initializing an array after a call to ArrayNew.

Returns

Returns the updated array.

Category

Function syntax

ArraySet(array, start_pos, end_pos, value)

See also

ArrayNewPopulating arrays with data in the Developing ColdFusion Applications

History

ColdFusion (2018 release): Returns the updated array.
ColdFusion MX: Changed behavior: This function can be used on XML objects.

Parameters

Parameter
Description
array
Name of an array.
start_pos
Starting index position of range to set.
end_pos
Ending index position of range to set. If this value is greater than array length, ColdFusion adds elements to array.
value
Value to which to set each element in the range.

Example

<cfscript>
    myArray=ArrayNew(1)
    temp = ArraySet(myArray, 1,6, "Initial Value")
    writeDump(myArray)
   // Set some values
    myArray[1] = "Sample Value"
    myArray[3] = "43" 
    myArray[6] = "Another Value"
    writeOutput("Updated array")
    writeDump(myArray)
</cfscript>
Output

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page