CFLib.org – Common Function Library Project

arrayDeleteArray(baseArray, deleteArray)

Last updated April 11, 2008

Version: 1 | Requires: ColdFusion MX | Library: DataManipulationLib

 
Rated 1 time(s). Average Rating: 5.0

Description:
Remove elements from one array which exist in another array. Uses Java's array.removeAll(str)

Return Values:
Returns an array.

Example:

view plain print about
<cfset myArray = ListToArray"Charlie,Jack,Kate,Libby,Sawyer" )>
<cfset deleteArray = ListToArray"Charlie,Libby" )>
<cfset myArray = arrayDeleteArray( myArray, deleteArray )>

Parameters:

Name Description Required
baseArray Main array of values. Yes
deleteArray Array of values to delete. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Remove elements from one array which exist in another array.
 * 
 * @param baseArray      Main array of values. (Required)
 * @param deleteArray      Array of values to delete. (Required)
 * @return Returns an array. 
 * @author Jason Rushton (jason@iworks.com) 
 * @version 1, April 11, 2008 
 */

function arrayDeleteArray( baseArray, deleteArray ) {
    arguments.baseArray.removeAll(arguments.deleteArray);
    return arguments.baseArray;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Henry Ho Henry Ho added
queryExecute
8 day(s) ago

Rick Root Rick Root added
deleteDirectory
11 day(s) ago

Troy Pullis Troy Pullis added
firstXDayOfMonth
a while ago

Henry Ho Henry Ho added
arrayMap
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 45 time(s)

Barney Boisvert indentXml
Rated 5.0, 12 time(s)

Rachel Lehman deAccent
Rated 5.0, 9 time(s)

Markus Schneebeli                                 ListRemoveByStri...
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson