| Contents > Developing ColdFusion MX Applications > Using Arrays and Structures > Basic array techniques > Creating arrays |
|
|
|
|
||
In ColdFusion, you declare an array by assigning a variable name to the new array and specifying its dimensions, as follows:
<cfset mynewarray=ArrayNew(x)>
where x is the number of dimensions (from 1 to 3) in the array that you want to create.
Once you declare an array, you can add array elements, which you can then reference using the elements' indexes.
For example, suppose you declare a 1D array called "firstname":
<cfset firstname=ArrayNew(1)>
The array firstname holds no data and is of an unspecified length. Next you add data to the array:
<cfset firstname[1]="Coleman"> <cfset firstname[2]="Charlie"> <cfset firstname[3]="Dexter">
After you add these names to the array, it has a length of 3.
|
|
||
| Contents > Developing ColdFusion MX Applications > Using Arrays and Structures > Basic array techniques > Creating arrays |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/arrayst7.htm