在Coldfusion中,如何向数组中的结构添加“列”?

在Coldfusion中,如何向数组中的结构添加“列”?,coldfusion,Coldfusion,例如,我有阵列广告,里面有图像 ads images url = someurl title = sometitle *here I want to add prop = someprop images url = someurl title = sometitle *here I want to add prop = someprop ads images url = someurl

例如,我有阵列广告,里面有图像

ads
   images
      url = someurl
      title = sometitle
      *here I want to add prop = someprop 
   images
      url = someurl
      title = sometitle
      *here I want to add prop = someprop
ads
   images
      url = someurl
      title = sometitle
      *here I want to add prop = someprop
现在我循环

<cfloop array="ads" index="i">
   <cfloop array="i.images" index="j">
      <cfif somecondition>
         <cfset prop = 'yes'>
      <cfelse>
         <cfset prop = 'no'>
      </cfif>
      <cfset ArrayAppend(i.images[j],prop)> ???
   </cfloop>
</cfloop>

我用ArrayAppend尝试了几种方法,尝试了StructAppend,但显然我无法理解我将如何进行。

我不知道cfloop的数组属性,但我认为这正是您想要的

<cfloop from="1" to="#arrayLen(ads)#" index="i" step="1">
     <cfset ads[i]["newprop"] = newpropvalue>
</cfloop>

我不知道cfloop的数组属性,但我认为这正是您想要的

<cfloop from="1" to="#arrayLen(ads)#" index="i" step="1">
     <cfset ads[i]["newprop"] = newpropvalue>
</cfloop>

你很接近。您只需在images循环中的项目上设置道具。这是假设i.images数组中的项是结构

<cfloop array="ads" index="i">
   <cfloop array="i.images" index="j">
      <cfif somecondition>
         <cfset j.prop = 'yes'>
      <cfelse>
         <cfset j.prop = 'no'>
      </cfif>
   </cfloop>
</cfloop>

你很接近。您只需在images循环中的项目上设置道具。这是假设i.images数组中的项是结构

<cfloop array="ads" index="i">
   <cfloop array="i.images" index="j">
      <cfif somecondition>
         <cfset j.prop = 'yes'>
      <cfelse>
         <cfset j.prop = 'no'>
      </cfif>
   </cfloop>
</cfloop>

事实就是这么简单!我在想办法让事情复杂化,就这么简单!我在想一个复杂化的方法,我在一个循环中有一个循环,并且正在努力解决这个问题,所以我没有在你们的解决方案中找到我的答案,因为我特别在努力解决双循环问题。我尝试将我的循环从一个循环更改为另一个循环,并使用类似于您的解决方案,但没有成功。数组属性确实存在,请参见下面Scott的答案,这就是关键所在。我在一个循环中有一个循环,并且一直在努力解决这个问题,所以我没有在您的解决方案中找到我的答案,因为我特别在努力解决双循环问题。我尝试将我的循环从一个循环更改为另一个循环,并使用类似于您的解决方案,但没有成功。数组属性确实存在,请参见下面Scott的答案。