3-1-Tags:CFBreak
last edited by
lmajano
on 23-Aug-2009
cfbreak
Description
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.
Category
Other
Implemented
Usage Syntax
<cfbreak />
[] = Optional attribute
Attributes
No Attributes
Example Usage
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>
SideBar
User Login
Comments (