Skip to main content
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

WolfShade
Legend
April 26, 2013

Does CFLOOP:index add 1 to the index when the loop is completed??

For ex:

<cfoutput>


<cfloop index="idx" from="1" to="4">
Index = #idx#<br />
</cfloop>
Index now = #idx#
</cfoutput>

 

Will output:

Index = 1

Index = 2

Index = 3

Index = 4

Index now = 5

_

Translate
Participating Frequently
April 29, 2013

Yes it does, and this is standard behaviour (not just limited to CFML). It increments 'idx'... once it's greater than the upper 'to' limit, then the loop stops.

Translate
WolfShade
Legend
April 29, 2013

I just found it odd that it would increment one more time after the loop is done processing.  I guess not that it really matters.. just unexpected by myself.

^_^

Translate