ArrayReverse(InArray)
Last updated October 09, 2001
Version: 1 | Requires: CF5 | Library: DataManipulationLib
Description:
Reverses the order of elements in a one-dimensional array. This function takes a one-dimensional array and returns a new one with the values from the first in reverse order.
Return Values:
Returna a new one dimensional array.
Example:
<CFSET Numbers = "1,2,3,4,5">
<CFSET NumbersArray = ListToArray(Numbers)>
<CFSET NumbersArray = ArrayReverse(NumbersArray)>
<CFLOOP INDEX="I" FROM="1" TO="#ArrayLen(NumbersArray)#">
<CFOUTPUT>
#NumbersArray[I]#<BR>
</CFOUTPUT>
</CFLOOP>
Parameters:
Name | Description | Required |
---|---|---|
InArray | One-dimensional array to be reversed. | Yes |
Full UDF Source:
/**
* Reverses the order of elements in a one-dimensional array.
*
* @param InArray One-dimensional array to be reversed.
* @return Returna a new one dimensional array.
* @author Raymond Simmons (raymond@terraincognita.com)
* @version 1.0, October 9, 2001
*/
function ArrayReverse(inArray){
var outArray = ArrayNew(1);
var i=0;
var j = 1;
for (i=ArrayLen(inArray);i GT 0;i=i-1){
outArray[j] = inArray[i];
j = j + 1;
}
return outArray;
}
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