| CFML Reference
|
|
ColdFusion Functions
|
ListPrepend
Description
Returns list with value inserted at the first position, shifting other elements to the right.
Category
List functions
Syntax
ListPrepend(list, value [, delimiters ])
See also
ListAppend, ListInsertAt, ListSetAt
Parameters
| Parameter |
Description |
list
|
A list
|
value
|
Number or list to prepend
|
delimiters
|
Set of delimiters used in list
|
Usage
When prepending an element to 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.
|
Note 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 ListPrepend --->
...
<!--- First, query to get some values for our list --->
<cfquery name = "GetParkInfo" datasource = "cfsnippets">
SELECT PARKNAME,CITY,STATE
FROM PARKS
WHERE PARKNAME LIKE 'DE%'
</cfquery>
<cfset temp = ValueList(GetParkInfo.ParkName)>
<cfset first_item = ListFirst(temp)>
<cfoutput>
<P>The original list: #temp#
</cfoutput>
<!--- now, insert an item at position 1--->
<cfset temp2 = ListPrepend(Temp, "my Inserted Value", ",")>
...
|
Copyright © 2001, Macromedia Inc. All rights reserved. |
|
|