CFLib.org – Common Function Library Project

ListFormatted(theList, beginStr, endStr[, theDelim])

Last updated June 26, 2002

author

Shawn Seley

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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson