LISTPREPEND | |
Description
Inserts an element at the beginning of a list. |
|
Returns
A copy of the list, with value inserted at the first position. |
|
Category
List functions |
|
Function syntaxListPrepend(list, value [, delimiters ]) |
|
See also
ListAppend, ListInsertAt, ListSetAt; "Lists" in Chapter 3, "Using ColdFusion Variables," in ColdFusion MX Developer's Guide |
|
Parameters
|
|
Usage
When prepending an element to a list, ColdFusion inserts a delimiter. If delimiters contains more than one delimiter character, ColdFusion uses the first delimiter in the string; if delimiters is omitted, ColdFusion uses a comma. ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements. If the delimiters parameter is the empty string (""), ColdFusion returns the contents of the value parameter. |
|
Example<!--- This example shows ListPrepend ---> <cfquery name = "GetParkInfo" datasource = "cfdocexamples"> SELECT PARKNAME,CITY,STATE FROM PARKS WHERE PARKNAME LIKE `DE%' </cfquery> <cfset temp = ValueList(GetParkInfo.ParkName)> <cfset first_element = ListFirst(temp)> <cfoutput><p>The original list: #temp#</cfoutput> <!--- now, insert an element at position 1---> <cfset temp2 = ListPrepend(Temp, "my Inserted Value")> |
LIST | |
VALUE | |
DELIMITERS | |