How to create a two dimensional array in ColdFusion

ArrayNew() - two dimensional array

ArrayNewTwoDimensions.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 two dimension array</title>
</head>

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

<cfset ColorArray=Arraynew(2)>

<cfset ColorArray[1][1]="Aquamarine">
<cfset ColorArray[1][2]="##7FFFD4">

<cfset ColorArray[2][1]="Azure">
<cfset ColorArray[2][2]="##F0FFFF">

<cfset ColorArray[3][1]="Beige">
<cfset ColorArray[3][2]="##F5F5DC">

<cfset ColorArray[3][1]="Bisque">
<cfset ColorArray[3][2]="##FFE4C4">

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

</body>
</html>





More ColdFusion examples