Tech Sharing

Tech Sharing

Advertisement

Looping over ColdFusion Structure

By on July 10, 2012

The following are the reference and sample code on how to loop over a structure without knowing its keys.

 

<cfset testStruct = structnew() />

<cfset testStruct.key1 = "test1" /> 
<cfset testStruct.key2 = "test2" /> 
<cfset testStruct.key3 = "test3" /> 
 
<cfdump var="#testStruct#" /> 
 
<cfloop list="#structKeyList(testStruct)#" index="key"> 
<cfoutput> 
Key: #key#, Value: #testStruct[key]# 
</cfoutput> 
</cfloop>

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Comments

No Responses to “Looping over ColdFusion Structure”

Write a Comment

Captcha * Time limit is exhausted. Please reload CAPTCHA.

%d bloggers like this: