Not exactly. You can do a foreach style loop over a structure, but even then
you are limited to looping over the key names rather than their values:
<cfloop collection="#myStruct#" item="myKey">
<cfoutput>#myStruct[myKey]#</cfoutput>
</cfloop>
Or...
<cfscript>
for (myKey in myStruct) {
writeOutput(myStruct[myKey]);
}
</cfscript>
There's no similar syntax for looping over the elements of an array. You're
limited to a for loop with arrays.
Ben Rogers
http://www.c4.net
v.508.240.0051
f.508.240.0057
________________________________________
From: Damien McKenna [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 11, 2004 11:58 AM
To: CF-Talk
Subject: "foreach"?
Is there any way to do a foreach-type loop in CFML?
--
Damien McKenna - Web Developer - [EMAIL PROTECTED]
The Limu Company - http://www.thelimucompany.com/ - 407-804-1014
"Nothing endures but change." - Heraclitus
________________________________________
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
- "foreach"? Damien McKenna
- Re: "foreach"? Bryan Stevenson
- RE: "foreach"? Guy Rish
- Re: "foreach"? Bryan Stevenson
- RE: "foreach"? Marlon Moyer
- Re: "foreach"? Damien McKenna
- RE: "foreach"? Spike
- Re: "foreach"? Benjamin S. Rogers
- Re: "foreach"? Ewok
- CFCHART Macromedia page broke Ewok
- Re: CFCHART Macromedia page broke Bryan Stevenson
- RE: "foreach"? Robertson-Ravo, Neil (RX)
- Re: "foreach"? Mike Kelp