Notice: With the launch of Adobe Cookbooks, this site will no longer be accepting new entries or posting new content. Thanks to everyone who submitted content!

How do I create an array with more than three dimensions?

ColdFusion lets you directly create arrays with up to three dimensions using the arrayNew() function. If you want to create a larger array, you can use multiple arrayNew() statements.

<cfset foo = arrayNew(3)>
<cfset foo[1][1][1] = arrayNew(3)>
<cfset foo[1][1][1][1][1][1] = "this is a test">

<cfoutput>#foo[1][1][1][1][1][1]#</cfoutput>


This question was written by Jeremy Petersen.
It was last updated on May 15, 2006 at 12:35:55 PM EDT.

CFML Referenced

ArrayNew()
<cfoutput>

Categories

Data Structures

Comments

Comment made by samon on May 17, 2006 at 11:10 PM
but How do I Sort an array with more than three dimensions?

because the query is only two dimensions


Comment made by Jeremy Petersen on May 18, 2006 at 12:37 PM
You could still use the query sorting tricks shown on: http://www.coldfusioncookbook.com/entry/87/How-do-I-sort-a-2-dimensional-array? It would just need to be expanded/changed to work with the more complex (larger) array.