Tech Sharing

Tech Sharing

Advertisement

Loop Over ColdFusion Structure

By on December 30, 2011

Just a quick reference on how to loop over a structure without knowing its keys. By the loop, you may also convert the structure

.

<cfset aaaa.ab1 = '111'>
<cfset aaaa.ab2 = '222'>
<cfset aaaa.ab3 = '333'>
<cfset aaaa.ab4 = '444'>

<cfset logcontent = "">
<cfloop list="#structKeyList(aaaa)#" index="key">
<cfoutput>
<cfset logcontent = logcontent & "(" & #key# & ": " & #aaaa[key]# & ")">
</cfoutput>
</cfloop>

<cfdump var="#aaaa#">

Comments

No Responses to “Loop Over ColdFusion Structure”

Write a Comment

Captcha *

%d bloggers like this: