Used to break out of the cfloop, cfwhile or cfforeach loops. Code execution picks up after after the closing loop tag. The break affects only the innermost loop.
Other
<cfbreak />
[] = Optional attribute
No Attributes
Example 1:
<p> Looping from 1 to 10: <cfloop from="1" to="10" index="i"> <cfoutput>#i# </cfoutput> <cfif i GT 4> Break! <cfbreak /> </cfif> </cfloop> </p> <p> Was prevented from fully looping by the cfbreak tag. </p>
Example 1:
<p> Looping from 1 to 10 with broken sub loop: <cfloop from="1" to="10" index="i"> <p> <cfoutput>Sub Loop #i#:</cfoutput> <cfset randomBreak = randRange(1,10) /> <cfloop from="1" to="10" index="i"> <cfoutput>#i# </cfoutput> <cfif i GT randomBreak> Break! <cfbreak /> </cfif> </cfloop> </p> </cfloop> </p> <p> Inner loops were prevented from fully looping by the cfbreak tag while the outer loop continued normally. </p>