Coldfusion8:如何创建关联数组?

时间:2012-05-11 13:14:20

标签: arrays coldfusion-8


我需要创建一个行数组“arrayOfQuoteLineItem”。代替位置值我必须关联位置的名称,如何在coldfusion8中做到这一点?我在coldfusion9的“http://www.bennadel.com/blog/1676-Learning-ColdFusion-9-Delete-Array-Elements-With-ArrayDelete-.htm”上看到了一些代码,但对于coldfusio8却没有?


QuoteLineItem
   nmfcClass = "100"
   weight = "300"

1 个答案:

答案 0 :(得分:1)

关联数组在CF中称为“结构”或“结构”。您可以在数组中嵌套结构,也可以在结构中或任何您需要的结构中嵌套结构。

<cfset quoteLineItems = arrayNew(1) /> <!--- or <cfset quoteLineItems = [] /> --->
<!--- probably some looping code here --->
<cfset st = structNew() /> <!--- or <cfset st = {} /> --->
<cfset st.nmfcClass = 100 />
<cfset st.weight = 300 />
<cfset arrayAppend(quoteLineItems, st) />
<!--- end loop --->