CFLib.org – Common Function Library Project

arrayDeleteArray(baseArray, deleteArray)

Last updated April 11, 2008

author

Jason Rushton

Version: 1 | Requires: CF6 | Library: DataManipulationLib

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

Return Values:
Returns an array.

Example:

<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:

/**
 * 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;
}
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