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

CF Ninja CF Ninja added
calcIRR
10 day(s) ago

Stephen Withington Stephen Withington added
getWeekOfMonth
10 day(s) ago

Adam Cameron Adam Cameron added
createPrimeNumbe...
a while ago

Ray Ford Ray Ford added
timeZoneNow
a while ago

Top Rated

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

Barney Boisvert indentXml
Rated 5.0, 12 time(s)

Rachel Lehman deAccent
Rated 5.0, 9 time(s)

Darwan Leonardo Sitepu splitNumber
Rated 5.0, 8 time(s)

Created by Raymond Camden / Design by Justin Johnson