ListInsertAt

Description

Returns list with value inserted at the specified position.

Category

List functions

Syntax


ListInsertAt(list, position, value [, delimiters ]) 

See also

ListDeleteAt, ListAppend, ListPrepend, ListSetAt

Parameters

Parameter
Description
list
A list.
position
Position in which to insert a value. The first position in a list is denoted by the number 1, not 0.
value
Number or list to insert.
delimiters
Set of delimiters used in list.

Usage

When inserting elements 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.


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 ListInsertAt --->

<!--- 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 insert_at_this_item = ListGetAt(temp, "3", ",")>

<cfoutput>

<P>The original list: #temp#

</cfoutput>

<!--- Now, insert an item at position three. --->

<cfset temp2 = ListInsertAt(Temp, "3", "my Inserted Value", ",")>



Banner.Novgorod.Ru