Copy link to clipboard
Copied
Hello,
I have a one dimensional array. Each element of the array has a simple structure in it.
How do I use cfloop and cfoutput to properly display each element in the array? CfDump works shows me that the array is defined properly.
Thank You!
Thalia
<cfoutput>
<cfloop from="1" to="#arrayLen(theArray)#" index="i">
<cfloop collection="#theArray#" item="structKey">
#theArray[structKey]#<br>
</cfloop>
<hr>
</cfloop>
That should give you some ideas.
Copy link to clipboard
Copied
<cfoutput>
<cfloop from="1" to="#arrayLen(theArray)#" index="i">
<cfloop collection="#theArray#" item="structKey">
#theArray[structKey]#<br>
</cfloop>
<hr>
</cfloop>
That should give you some ideas.
Copy link to clipboard
Copied
Thank you, Ian. That's easy and just what I'm looking for!
Copy link to clipboard
Copied
Lan, your method is so simple, and still work. Thanks.
Copy link to clipboard
Copied
Each element of the array has a simple structure in it.
How do I use cfloop and cfoutput to properly display each element in the array?
You cannot use cfoutput to display a structure. Use cfdump to display the structures, and Ian's code to display the value corresponding to the keys.
<cfoutput>
<cfloop from="1" to="#arrayLen(theArray)#" index="i">
<!--- display array elements, which are structs --->
<cfdump var="#theArray#">
<br>
<hr>
</cfloop>