I have two dimensional array that looks like this after I used to output this on the screen:
array
1
array
1 0600
2
array
1 0
3
array
1 0600
4
array
1 0
5
array
1 0615
6
array
1 0
7
array
1 0615
8
array
1 0
9
array
1 0630
10
array
1 0
11
array
1 0630
12
array
1 1
So I want to loop through my array and output values in this order:
0600 0
0600 0
0615 0
0615 0
0630 0
0630 1
Here is the code how I created my Array:
<cfloop list="#ListGetAt(dataList,i,",")#" index="z" delimiters="|">
<cfoutput query="getR" group="theYear">
<cfset name = myArray.append([z])>
<cfif Description eq z>
<cfset count = myArray.append([theCount])>
<cfelse>
<cfset count = myArray.append([0])>
</cfif>
</cfoutput>
</cfloop>
So how I can loop now to get this two records in order as I showed you above? I tried this but that did not work:
<cfoutput>
<cfloop from="1" to="#arraylen(myArray)#" index="i">
<cfloop array="#myArray#" index="j">
#i# - #myArray[1][j]#<br/>
</cfloop>
</cfloop>
</cfoutput>
Edit: When I used this code:
<cfloop array="#myArray#" index="i">
<cfloop array="#myArray#" index="j">
<cfoutput> #myArray[i][j]#<br/> </cfoutput>
</cfloop>
</cfloop>
I got this error:
The value coldfusion.runtime.Array cannot be converted to a number.
If anyone can help with this problem please let me know.
indexwill contain the value of one of the elements in the array. However, the output code is designed for use with a from/to loop, where theindexvalue is a position or number, ie 1,2,3,etc...