函数调用中的 cfloop 索引输出
cfloop index output in function call
我有一个循环,我需要将其添加到函数调用的索引中。我该怎么做?
这是我尝试过但失败的方法
<cfloop index="i" from="1" to="#arrayLen(test)#">
#session_ID & i &.getSessionCount()#
</cfloop>
循环的索引应输出,以便循环的每次迭代都将如下所示:
#session_ID1.getSessionCount()#
#session_ID2.getSessionCount()#
#session_ID3.getSessionCount()#
#session_ID4.getSessionCount()#
等等。
如果需要动态创建变量名,则使用关联数组表示法而不是点表示法,并通过变量所在的范围引用变量。EG:
<cfloop index="i" from="1" to="#arrayLen(test)#">
<cfset result = variables["session_ID" & i].getSessionCount()>
</cfloop>
我有一个循环,我需要将其添加到函数调用的索引中。我该怎么做?
这是我尝试过但失败的方法
<cfloop index="i" from="1" to="#arrayLen(test)#">
#session_ID & i &.getSessionCount()#
</cfloop>
循环的索引应输出,以便循环的每次迭代都将如下所示:
#session_ID1.getSessionCount()#
#session_ID2.getSessionCount()#
#session_ID3.getSessionCount()#
#session_ID4.getSessionCount()#
等等。
如果需要动态创建变量名,则使用关联数组表示法而不是点表示法,并通过变量所在的范围引用变量。EG:
<cfloop index="i" from="1" to="#arrayLen(test)#">
<cfset result = variables["session_ID" & i].getSessionCount()>
</cfloop>