ListElementPrepend(list, string[, delim])
Last updated September 21, 2004
Version: 2 | Requires: CF5 | Library: StrLib
Description:
Prepends a string to every item in a list.
Return Values:
Returns a list.
Example:
<cfset list = "a,b,c">
<cfoutput>#listElementPrepend(list,"foo")#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
list | List to modify. | Yes |
string | String to prepend. | Yes |
delim | Delimiter. Defaults to a comma. | No |
Full UDF Source:
/**
* Prepends a string to every item in a list.
* Version 2 by Raymond Camden
*
* @param list List to modify. (Required)
* @param string String to prepend. (Required)
* @param delim Delimiter. Defaults to a comma. (Optional)
* @return Returns a list.
* @author SHUM Ting-hin (gene_shum@iclp.com.hk)
* @version 2, September 21, 2004
*/
function listElementPrepend(list,string) {
var delim = ",";
var i = "";
if(arrayLen(arguments) gte 3) delim = arguments[3];
for(i=1; i lte listLen(list); i=i+1) {
list = listSetAt(list, i, string & listGetAt(list,i));
}
return list;
}
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