arrayNew
Description
Creates an array of 1–3 dimensions. Index array elements with square brackets: [ ].
Categories
Syntax
ArrayNew(dimension)
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| dimension | Number of dimensions in new array: 1, 2, or 3 |
Returns
An array
Example
<h3>ArrayNew Example</h3>
<!--- Create an array. --->
<cfset MyNewArray = ArrayNew(1)>
<!--- ArrayToList does not function properly if the Array is not initialized with
ArraySet --->
<cfset temp = ArraySet(MyNewArray, 1,6, "")>
<!--- Set some elements. --->
<cfset MyNewArray[1] = "Sample Value">
<cfset MyNewArray[3] = "43">
<cfset MyNewArray[6] = "Another Value">
<!--- Is it an array? --->
<cfoutput>
Is this an array? #IsArray(MyNewArray)#</p>
It has #ArrayLen(MyNewArray)# elements.</p>
Contents: #ArrayToList(MyNewArray)#</p>
<!--- The array has expanded dynamically to six elements with the use of ArraySet,
even though we only set three values. --->
</cfoutput>