ListToArray

Description

Converts a list to an array.

Category

List functions

Syntax


ListToArray(list [, delimiter ]) 

See also

ArrayToList

Parameters

Parameter
Description
list
Name of the list variable that contains the elements to use to build an array. You define a list variable with a CFSET statement. The list items must be separated by commas or another delimiter.
delimiter
The character(s) used to delimit list elements. Default is comma.

Usage

ColdFusion ignores empty list elements; thus, a list that is defined as "a,b,c,,,d" is treated as a four element list.

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">

SELECT  Username, 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>    







Banner.Novgorod.Ru