␡
- Introduction
- Creating an Array
- Adding an Element to an Array
- Displaying a Value in an Array
- Looping over an Array
- Manipulating Array Values
- Sorting an Array
- Multidimensional Arrays
- Creating Arrays with More Than Three Dimensions
- Array Aggregate Functions
- Array Utility Functions
- Array Information Functions
This chapter is from the book
3.8. Creating Arrays with More Than Three Dimensions
You want to create an array with more than three dimensions.
Technique
Define multiple dimensions in an array by creating three dimensions at a time with ArrayNew().
<!---create three dimensional aDeepArray array---> <cfset aDeepArray = ArrayNew(3)> <!---build nine dimensions---> <cfset aDeepArray[1][1][1] = ArrayNew(3)> <cfset aDeepArray[1][1][1][1][1][1] = ArrayNew(3)> <cfset aDeepArray[1][1][1][1][1][1][1][1][1] = "I'm in the ninth dimension"> <!----display first element in ninth dimension---> <cfoutput> #aDeepArray[1][1][1][1][1][1][1][1][1]# </cfoutput>
Comments
Although ArrayNew()lets you define only three dimensions, should the need arise you can bypass this constraint by setting any of the three dimension values to an array itself and repeat until you have the dimension depth you require. The code in this example places a string value in the lowly ninth dimension.