Returns list with value appended to its last element.
ListAppend(list, value [, delimiters ])
ListPrepend,
ListInsertAt,
ListSetAt
Parameter |
Description |
---|---|
list |
A list |
value |
Number or list to append |
delimiters |
Set of delimiters used in list |
When appending an element into a list, ColdFusion inserts a delimiter. If delimiters contains more than one delimiter, ColdFusion defaults to the first delimiter in the string, or a comma, if delimiters was omitted.
If you intend to use list functions on strings that are delimited by the conjunction ", " (comma-space), as is common in HTTP header strings such as the COOKIE header, we recommend that you specify delimiters to include both comma and space, because ColdFusion Server does not skip white space. For example,
ListAppend(List, "MyCookie", "," & CHR(32))
Note ColdFusion ignores empty list elements; thus, a list that is defined as "a,b,c,,,d" is treated as a four element list. |
<!--- This example shows ListAppend ---> <html> <head> <title>ListAppend Example</title> </head> <body> <H3>ListAppend Example</H3> <!--- First, query to get some values for our list ---> <cfquery name = "GetParkInfo" datasource = "cfsnippets"> SELECT PARKNAME,CITY,STATE FROM PARKS WHERE PARKNAME LIKE 'AL%' </cfquery> <cfset temp = ValueList(GetParkInfo.ParkName)> <cfoutput> <P>The original list: #temp# </cfoutput> <!--- now, append a park name to the list ---> <cfset temp2 = ListAppend(Temp, "ANOTHER PARK", ",")> ...