CFLib.org – Common Function Library Project

ArrayConcat(a1, a2)

Last updated September 13, 2001

author

Craig Fisher

Version: 1 | Requires: CF5 | Library: DataManipulationLib

Description:
Take two arguments, Array1 and Array2. Concatenates Array2 to the end of Array1.

Return Values:
Returns an array.

Example:

<CFSCRIPT>
a1=ArrayNew(1);
a1[1]=1;
a1[2]=2;
a1[3]=3;
a1[4]=4;
a1[5]=5;
a1[6]=6;
a2=ArrayNew(1);
a2[1]="a";
a2[2]=structNew();
a2[2].cheese="fgfgfg";
a2[3]="c";
a2[4]="d";
a3=ArrayConcat(a1, a2);
</cfscript>
a1:
<CFDUMP var="#a1#">
a2:
<CFDUMP var="#a2#">
a3:
<CFDUMP var="#a3#">

Parameters:

Name Description Required
a1 The first array. Yes
a2 The second array. Yes

Full UDF Source:

/**
 * Concatenates two arrays.
 * 
 * @param a1 	 The first array. 
 * @param a2 	 The second array. 
 * @return Returns an array. 
 * @author Craig Fisher (craig@altainetractive.com) 
 * @version 1, September 13, 2001 
 */
function ArrayConcat(a1, a2){
	var i=1;
	if ((NOT IsArray(a1)) OR (NOT IsArray(a2))) {
		writeoutput("Error in <Code>ArrayConcat()</code>! Correct usage: ArrayConcat(<I>Array1</I>, <I>Array2</I>) -- Concatenates Array2 to the end of Array1");
		return 0;
	}
	for (i=1;i LTE ArrayLen(a2);i=i+1) {
		ArrayAppend(a1, Duplicate(a2[i]));
	}
	return a1;
}
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