Deletes an element from a list.
A copy of the list, without the specified element.
ListDeleteAt(list, position [, delimiters ]) ListDeleteAt(list, position [, delimiters, includeEmptyValues ])
ListGetAt, ListSetAt, ListLen; Lists in Data types- Developing guide in the Developing ColdFusion Applications
Parameter |
Description |
|---|---|
list |
A list or a variable that contains one. |
position |
A positive integer or a variable that contains one. Position at which to delete element. The first list position is 1. |
delimiters |
A string or a variable that contains one. Characters that separate list elements. The default value is comma. If this parameter contains more than one character, ColdFusion processes each occurrence of each character as a delimiter. |
includeEmptyValues |
If includeEmptyValues is set to false, the list will contain only nonempty elements and the element would be deleted at the specified position. |
To use this and other functions with the default delimiter (comma), you can code as follows:
<cfset temp2 = ListDeleteAt(temp, "3")>
To specify another delimiter, you code as follows:
<cfset temp2 = ListDeleteAt(temp, "3", ";")>
<cfscript>
myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai";
WriteOutput(ListDeleteAt(myList,3) & " * "); //Deletes Jakarta at index 3
mySecondList="London,Paris|Sau Paulo,Santiago,Buenos Aires|New York,Montreal,Seattle|Tokyo,Shanghai";
WriteOutput(ListDeleteAt(mySecondList,3,"|")); //Deletes index 3 using custom delimiter
</cfscript>
Output
Tokyo,Bangkok,Manila,Bangalore,Shanghai * London,Paris|Sau Paulo,Santiago,Buenos Aires|Tokyo,Shanghai
Sign in to your account