Well it is already a common list and there are a number of list functions
readily available in CF as well as a "list" type available in cfloop. There
is also listtoArray() which is what you are looking for in this case.

Just give it the list variable and delimiter (default delimiter is a comma
so just give it the list variable in your case)

<cfset category = "one,two,three" />

<cfset myNewArray = listToArray(category) />

<cfloop from="1" to="#arraylen(myNewArray)#" index="i">
#myNewArray[i]#<br />
</cfloop>



You can also just write your own explode() function if that makes you feel
better ;-)


<cfscript>
function explode(theList) {
        return listtoArray(theList);
}
</cfscript>


<cfset category = "one,two,three" />
<cfdump var="#explode(category)#" />


You would need to expand on that function to accommodate delimiters other
than the default comma.

..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com


-----Original Message-----
From: nicolai bass dh [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 23, 2007 11:07 AM
To: CF-Talk
Subject: Explode a string to single values

Hi,

i´m a CF newbie and i have a question:

I want to explode a variable into the single values. For example:
<cfset category="one,two,three">
I want to known the single values, seperated by "," and want to place them
in an array.

I know the PHP function explode(). Is there a similar function in CF?

Thanks a lot & with best regards.

Nic.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:286953
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to