CFLib.org – Common Function Library Project

Array([paramN])

Last updated July 3, 2002

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

 
Rated 1 time(s). Average Rating: 5.0

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:

view plain print about
<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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
4 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

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

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson