CFLib.org – Common Function Library Project

ArrayDeleteAtList(a, l)

Last updated January 21, 2005

author

Giampaolo Bellavite

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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson