How to create a three dimensional array in ColdFusion

ArrayNew() - three dimensional array

ArrayNewThreeDimensions.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ArrayNew function example: how to create a three dimension array</title>
</head>

<body>
<h2 style="color:Crimson">ArrayNew function Example: Three Dimensions</h2>

<cfset ColorArray=Arraynew(3)>

<cfset ColorArray[1][1][1]="1">
<cfset ColorArray[1][1][2]="Red">
<cfset ColorArray[1][1][3]="##FF0000">

<cfset ColorArray[1][2][1]="2">
<cfset ColorArray[1][2][2]="IndianRed">
<cfset ColorArray[1][2][3]="##CD5C5C">


<cfset ColorArray[2][1][1]="1">
<cfset ColorArray[2][1][2]="Green">
<cfset ColorArray[2][1][3]="##008000">

<cfset ColorArray[2][2][1]="2">
<cfset ColorArray[2][2][2]="GreenYellow">
<cfset ColorArray[2][2][3]="##ADFF2F">


<cfdump var="#ColorArray#" label="ColorArray[Three Dimensions]">

</body>
</html>






More ColdFusion examples