ListFormatted(theList, beginStr, endStr[, theDelim])
Last updated June 26, 2002
Version: 1 | Requires: CF5 | Library: StrLib
Description:
Adds formatting to list elements by wrapping each element between beginStr and endStr. Special delimeters (non-comma) can be specified in the optional final argument.
Return Values:
Returns a string.
Example:
<cfset my_list = "one,two,three">
<cfoutput><ol>#ListFormatted(my_list,"<li>","</li>")#</ol></cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
theList | The list to modify. | Yes |
beginStr | The string to prepend to each list element. | Yes |
endStr | The string to append to each list element. | Yes |
theDelim | List delimiter. Defaults to a comma. | No |
Full UDF Source:
/**
* Adds formatting to list elements, for displaying lists in a more readable fashion.
*
* @param theList The list to modify. (Required)
* @param beginStr The string to prepend to each list element. (Required)
* @param endStr The string to append to each list element. (Required)
* @param theDelim List delimiter. Defaults to a comma. (Optional)
* @return Returns a string.
* @author Shawn Seley (shawnse@aol.com)
* @version 1, June 26, 2002
*/
function ListFormatted(theList, beginStr, endStr) {
var theDelim = ",";
if(ArrayLen(Arguments) GTE 4) theDelim = Arguments[4];
return beginStr & Replace(theList, theDelim, endStr & beginStr, "ALL") & endStr;
}
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