274
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>
CFML Language Reference
Need help?
Do you have a question about the COLDFUSION 4.5-CFML LANGUAGE and is the answer not in the manual?
Questions and answers