ArrayToList

Converts the specified one dimensional array to a list, delimited with the character you specify.

Syntax

ArrayToList(array [, delimiter ])
array

Name of the array containing elements you want to use to build a list.

delimiter

Specify the character(s) you want to use to delimit elements in the list. Default is comma ( , ).

Example

<!--- This example shows ArrayToList --->

<HTML>
<HEAD>
<TITLE>ArrayToList Example</TITLE>
</HEAD>

<BODY>
<CFQUERY NAME="GetEmployeeNames" DATASOURCE="cfsnippets">
SELECT FirstName, LastName FROM Employees
</CFQUERY>
<!--- create an array --->
<CFSET myArray = ArrayNew(1)>
<!--- loop through the query and append these names
successively to the last element --->
<CFLOOP query="GetEmployeeNames">
    <CFSET temp= ArrayAppend(myArray, "#FirstName# #LastName#")>
</CFLOOP>
<!--- show the resulting array as a list --->
<CFSET myList=ArrayToList(myArray, ",")>
<!--- sort that array descending alphabetically --->
<CFSET myAlphaArray = ArraySort(myArray, "textnocase", "desc")>
<!--- show the resulting alphabetized array as a list --->
<CFSET myAlphaList=ArrayToList(myArray, ",")>
<!--- output the array as a list --->
<CFOUTPUT>
    <P>The contents of the array are as follows:
    <P>#myList#
    <P>This array, alphabetized by first name (descending):
    <P>#myAlphaList#
    <P>This array has #ArrayLen(MyArray)# elements.
</CFOUTPUT>
</BODY>
</HTML>       

1