ArrayDeleteAtList(a, l)
Last updated January 21, 2005
Version: 1 | Requires: ColdFusion 5 | 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[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:
<cfscript>
/**
* 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;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
11 day(s) ago
Will Belden added
longTime
17 day(s) ago
James Sleeman added
quickSort
27 day(s) ago
Ben Forta added
GetHostAddress
30 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)