Looping over a list using the CFLOOP tag in ColdFusion

Readability

Looping over a list using the CFLOOP tag in ColdFusion

The fol­low­ing exam­ple shows how you can loop over a list using the <CFLOOP> tag and index and list attrib­utes in ColdFusion.


    #uCase(obj)#

The pre­ced­ing code pro­duces the fol­low­ing output:

THE
QUICK
BROWN
FOX
JUMPS
OVER
THE
LAZY
DOG

The default delim­iter is a comma, but if you want to spec­ify one or more cus­tom delim­iters you can spec­ify the delimiters attribute on the <CFLOOP> tag, as seen in the fol­low­ing example:


    #uCase(obj)#

The pre­ced­ing code pro­duces the fol­low­ing output:

THE
QUICK
BROWN
FOX
JUMPS
OVER
THE
LAZY
DOG

The following example shows how you can loop over a list using the <CFLOOP> tag and index and list attributes in ColdFusion.

<cfloop index="obj" list="The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog">
    <cfoutput>#uCase(obj)#<br/></cfoutput>
</cfloop>

The preceding code produces the following output:

THE
QUICK
BROWN
FOX
JUMPS
OVER
THE
LAZY
DOG

The default delimiter is a comma, but if you want to specify one or more custom delimiters you can specify the delimiters attribute on the <CFLOOP> tag, as seen in the following example:

<cfloop index="obj" list="The;Quick;Brown,Fox;Jumps;Over;The;Lazy|Dog" delimiters=",;|">
    <cfoutput>#uCase(obj)#<br/></cfoutput>
</cfloop>

The preceding code produces the following output:

THE
QUICK
BROWN
FOX
JUMPS
OVER
THE
LAZY
DOG

Leave a Reply

Your email address will not be published.