Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recorre string

Status
Not open for further replies.

cfm

Programmer
Mar 27, 2001
76
CL

I have a string

strtmp=jh@netexplora.com,jp@netexplora.com,jhm@net.com

How I can separate values??

example:
var1:jh@netexplora.com
var2:jp@netexplora.com
var3:jhm@net.com

I Thought this:

<cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;#len(strtmp)#&quot; step=&quot;1&quot;>
<cfoutput>#strtmp#</cfoutput>
</cfloop>

but, I know what this does not work!!

thanks
 
Dear cfm -

A string with comma separated values counts as a *list*. This means a whole host of list functions are suddenly available to you for manipulating strtmp.

The following segment initialises an array (separated_items), then loops through your list (strtmp) placing each item into successive elements in the array.

Code:
<cfset number_of_items = ListLen(strtmp)>
<cfset separated_items = ArrayNew(1)>

<cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;#number_of_items#&quot;>
   <cfset separated_items[i] = ListGetAt(strtmp,i)>
</cfloop>

The elements of strtmp are now in the array for you to use separately.

Lists are, by default, comma-separated. If you use another character to separate items, you'll need to specify this as an argument of the 'ListGetAt' function. See your CF manual to check out other list functions.


Tam.
 
thanks

I 'am had other method not optimal!!!

thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top