Looping over a ColdFusion Array (In ColdFusion 8)

Wednesday I blogged about ColdFusion arrays and today I got permission to mention another new feature in ColdFusion 8 - Array-based CFLOOP. In the past you would loop over an array like so:

<cfloop index="x" from="1" to="#arrayLen(arr)#"> <cfoutput>#arr[x]#<br /></cfoutput> </cfloop>

ColdFusion 8 adds a new array attribute to cfloop so you can do this instead:

<cfloop index="x" array="#arr#"> <cfoutput>#x#<br /></cfoutput> </cfloop>

I don’t think this has been shared yet publicly, so enjoy, and remember that I was given permission to share this. This weekend I think I’ll resurrect my ‘Known Facts’ blog post and update it with all the juicy bits that have been revealed lately.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments