arrays - cfloop 一个数组并逐行读取内容

标签 arrays coldfusion cfloop

我只是想知道在 ColdFusion 中是否有一种方法可以循环遍历文本数组,然后逐行循环遍历文本?

<cfloop file= "#ExpandPath('/file-path-here')#" index="theLine">
</cfloop>

上面的cfloop循环遍历一个文件。但是,我希望循环遍历包含大量文本的现有数组。然后循环每一行内容。 CF 可以做到这一点吗?

最佳答案

是的。只需循环数组...在该循环内,您对每个文件使用上述循环。

抱歉,请重新阅读问题。 是的,你循环遍历数组。然后将数组项内容视为列表... Cfloop list= array item... Delimiter = Cr 或 lf

<cfloop array="#myarray#" index="arrayItem">
    <cfloop index="theLine" list="#arrayItem#" delimiters="#chr(10)##chr(13)#">
        <cfset doSomethingWithIt = theLine> 
    </cfloop>
</cfloop>

关于arrays - cfloop 一个数组并逐行读取内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21617906/

相关文章:

arrays - 如何循环遍历逻辑应用程序中的数组?

c++ - C++ 映射中的 C 风格数组

apache - 如何将本地主机应用程序服务器从 Apache httpd 更改为 ColdFusion 10 中内置的 Tomcat?

string - Coldfusion:将新行插入字符串

arrays - 如何在 Coldfusion 中附加 <cfloop> 中的数组值?

java - 在我的字符数组中查找特殊字符的数量

python - python 中的 4 维零数组

apache - 如何使 cfimage 在 Apache 上与 ColdFusion 10 一起工作?

loops - 用cfloop订购

coldfusion - 循环 Cfquery 还是 Struct?