ArrayDeleteAtList(a, l)
Last updated January 21, 2005
Version: 1 | Requires: CF5 | Library: DataManipulationLib
Description:
Deletes elements from an array passing the list of positions.
Similar to ArrayDeleteAt but the position value could be a list of positions.
Return Values:
Returns an array.
Example:
<cfset myArr=ArrayNew(1)>
<cfset myArr[1]="1st">
<cfset myArr[2]="2nd">
<cfset myArr[3]="3rd">
<cfset myArr[4]="4th">
<cfset myArr[5]="5th">
<cfdump var="#myArr#" label="Original array">
<cfset list='1,5'>
To delete: <br />
<cfoutput>#list#</cfoutput><br />
<cfdump var="#ArrayDeleteAtList(myArr,list)#" label="parsedArray">
Parameters:
Name | Description | Required |
---|---|---|
a | The array to modify. | Yes |
l | The list of indexes to remove. | Yes |
Full UDF Source:
/**
* Deletes an elements list from an array.
*
* @param a The array to modify. (Required)
* @param l The list of indexes to remove. (Required)
* @return Returns an array.
* @author Giampaolo Bellavite (giampaolo@bellavite.com)
* @version 1, January 21, 2005
*/
function ArrayDeleteAtList(a,l) {
var i=1;
l = listSort(l, "numeric", "desc");
for(i=1; i lte listLen(l); i=i+1) arrayDeleteAt(a, listGetAt(l,i));
return a;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016