User Guide

430 CFML Language Reference
ListToArray
Converts the specified list into an array.
See also ArrayToList.
Syntax ListToArray(
list
[,
delimiter
])
list
Name of the list variable that contains the elements to be used to build an array.
You can define a list variable with a CFSET statement. The items in the list must be
separated by commas or otherwise delimited.
delimiter
Specify the character(s) used to delimit elements in the list. Default is comma ( , ).
Example <!--- This example shows ListToArray --->
<HTML>
<HEAD>
<TITLE>ListToArray Example</TITLE>
</HEAD>
<BODY>
<H3>ListToArray Example</H3>
<!--- Find a list of users who wrote messages --->
<CFQUERY NAME="GetMessageUser" DATASOURCE="cfsnippets">
SELECTUsername, Subject, Posted
FROM Messages
</CFQUERY>
<CFSET myList = ValueList(GetMessageUser.UserName)>
<P>My list is a list with <CFOUTPUT>#ListLen(myList)#</CFOUTPUT>
elements.
<CFSET myArrayList = ListToArray(myList)>
<P>My array list is an array with <CFOUTPUT>#ArrayLen(myArrayList)#
</CFOUTPUT> elements.
</BODY>
</HTML>