CFLib.org – Common Function Library Project

Array([paramN])

Last updated July 3, 2002
Download UDF

author

Erki Esken                                        Erki Esken

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

Description:
Now you can make simple or complex arrays with a one-liner in CF, just like with built-in shorthand syntax in many other programming languages. You can create simple 1D arrays with ease, or nest Array() functions to create complex 2D, 3D etc arrays.

Return Values:
Returns an array.

Example:

<cfdump var="#Array('one','two','three',Array('foo','bar','quux'))#">

Parameters:

Name Description Required
paramN This UDF accepts N optional arguments. Each argument is added to the returned array. No

Full UDF Source:

<cfscript>
/**
* This functions helps to quickly build arrays, both simple and complex.
*
* @param paramN      This UDF accepts N optional arguments. Each argument is added to the returned array. (Optional)
* @return Returns an array.
* @author Erki Esken (erki@dreamdrummer.com)
* @version 1, July 3, 2002
*/

function Array() {
    var result = ArrayNew(1);
    var to = ArrayLen(arguments);
    var i = 0;
    for (i=1; i LTE to; i=i+1)
        result[i] = Duplicate(arguments[i]);
    return result;
}
</cfscript>

Search CFLib.org


Latest Additions

Jose Diaz-Salcedo Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago

Raymond Compton Raymond Compton added
structBlend
23 day(s) ago

Duncan Duncan added
IsZIPUK
23 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
29 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson