looping over Arrays

Yippee we can now easily loop over arrays in CF8.

<cfloop array="arrayname" index="i">
<cfoutput>#i#</cfoutput>
</cfloop>

#i# will show us the values in the array. You can ofcourse apply logic to the output so that dates an numbers are formatted.

Consider this array for a contact application.
Bob, Jones, 123 mainstreet, anytown, ST, USA, 555-123-4567, 14-NOV-1963.
Firsname, lastname, address, city, state, country, phone, birthdate.

<cfloop array="arrayname" index="i">
<cfoutput>
<cfif isDate(i)>#dateformat(i,"mm/dd/yyyy")#
<cfelse> #i#
<cfif>
</cfoutput>
</cfloop>

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion, Snippets. Bookmark the permalink.