[thelist] ColdFusion and ListToArray() - more than one character

Bruce Heerssen bheerssen at visualbridge.tv
Wed Apr 25 17:51:22 CDT 2001


This is problematical because when CF is presented with a list of delimiters for a list string, it interprets the list as being
delimited by *any one* of the list of delimiters. So, your test array here would actually be:

arr[1] = '1'
arr[2] = ''
arr[3] = ''
arr[4] = ''
arr[5] = ''
arr[6] = ''
arr[7] = '2'

etc...


Here's a solution - replace your list of delimiters with a single delimiter, eg:

<cfset theList = "1Hello2Hello3Hello4">
<cfset temp = replace(theList,"Hello",",","All")>
<cfset arr = listToArray(temp)>
<cfoutput>
<cfloop from="1" to="#arrayLen(arr)#" index="i">
arr[#i#] = '#arr[i]#'<br>
</cfloop>
</cfoutput>

If the comma is not a good delimiter for you, then pick another one (like a pipe [|] symbol).

-Bruce

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of jon steele
> Sent: Wednesday, April 25, 2001 5:32 PM
> To: thelist at lists.evolt.org
> Subject: [thelist] ColdFusion and ListToArray() - more than one
> character
>
>
> Hi,
>
> I knew how to do this before but I forgot...:) I need to use the
> ListToArray() function but the delimiter being MORE than one character
> (e.g. <cfset arr = ListToArray("1Hello2Hello3Hello4","Hello")> would
> give arr[1]=1, arr[2]=2, arr[4]=3, arr[4]=4.
>
> Thanks,
> Jon.
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list