Creates an array of 1 to 3 dimensions. Array elements are indexed with square brackets: [ ].
ColdFusion arrays expand dynamically as data is added.
ArrayNew(dimension)
Parameter |
Description |
---|---|
dimension |
1, 2, or 3 |
<!--- This example shows ArrayNew ---> <html> <head> <title>ArrayNew </title> </head> <body> <H3>ArrayNew Example</H3> <!--- Make an array ---> <cfset MyNewArray = ArrayNew(1)> <!--- ArrayToList will not function properly if the Array has not been 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> <P>Is this an array? #IsArray(MyNewArray)# <P>It has #ArrayLen(MyNewArray)# elements. <P>Contents: #ArrayToList(MyNewArray)# <!--- the array has expanded dynamically to six elements with the use of ArraySet, even though we only set three values ---> </cfoutput> </body> </html>