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

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson