Skip to main content
Participant
October 23, 2009
Answered

Array of Structures

  • October 23, 2009
  • 2 replies
  • 850 views

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

This topic has been closed for replies.
Correct answer ilssac

<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.

2 replies

BKBK
Community Expert
Community Expert
October 24, 2009

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>

ilssac
ilssacCorrect answer
Inspiring
October 23, 2009

<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.

Participant
October 26, 2009

Thank you, Ian.  That's easy and just what I'm looking for!