Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Array of Structures

New Here ,
Oct 23, 2009 Oct 23, 2009

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

TOPICS
Getting started
816
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Oct 23, 2009 Oct 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.

Translate
Valorous Hero ,
Oct 23, 2009 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 26, 2009 Oct 26, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2009 Nov 05, 2009
LATEST

Lan, your method is so simple, and still work. Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2009 Oct 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources