Name

StructKeyArray — New as of ColdFusion 4.01

Synopsis

StructKeyArray(structure)

Returns an array containing all the keys in structure. Here’s an example that lists all the keys contained in a structure called Stock:

<CFSET Stock = StructNew(  )>
<CFSET Stock.Company = "Allaire">
<CFSET Stock.Ticker = "ALLR">
<CFSET Stock.Exchange = "NASDAQ">
<CFSET Stock.Price = "66.25">
<CFSET Stock.Change = "+0.375">
<CFSET Stock.LastTradeTime = "10:17AM">
<CFSET Stock.LastTradeDate = "05/17/1999">
<CFSET Stock.Volume = "8300">

<CFSET MyKeyArray = StructKeyArray(Stock)>

<TABLE>
  <TR><TH>Key #</TH><TH>Name</TH><TH>Value</TH></TR>
<CFLOOP index="position" from="1" to="#ArrayLen(MyKeyArray)#">
<CFOUTPUT>
  <TR><TD>#position#:</TD><TD>#MyKeyArray[position]#</TD>
    <TD>#Stock[MyKeyArray[position]]#</TD></TR>
</CFOUTPUT>
</CFLOOP>
</TABLE>

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.