Admin User     Feb,08 2017

Loop Over A Structure Using CFScript

Looping Over A Structure in CFScript is possible using the FOR ( key In Structure) Notation.

The following code demonstrates how to loop over a structure based on the keys existing in the structure;

<cfscript>myStruct = StructNew();myStruct.FirstName = "Andrew";myStruct.LastName = "Hall";for(key in myStruct) {writeOutput(key & " = " & myStruct[key] & "<br />");}</cfscript>

Above Code Will Give The Following Output;

FIRSTNAME = AndrewLASTNAME = Hall