ListLongestItem(list[, delim])
Last updated September 21, 2004
Version: 1 | Requires: CF5 | Library: StrLib
Description:
Returns the first occurrence of the longest item in a list.
Return Values:
Returrns a string.
Example:
<cfscript>
myList = "CFLib has the greatest collection of UDF functions.";
writeoutput(ListLongestItem(myList," "));
</cfscript>
Parameters:
Name | Description | Required |
---|---|---|
list | The list to parse. | Yes |
delim | List delimiter. Defaults to a comma. | No |
Full UDF Source:
/**
* Returns the first occurrence of the longest item in a list.
*
* @param list The list to parse. (Required)
* @param delim List delimiter. Defaults to a comma. (Optional)
* @return Returrns a string.
* @author Joseph Flanigan (joseph@switch-box.org)
* @version 1, September 21, 2004
*/
function listLongestItem(list){
var delim = ",";
var item = "";
var i = 0;
if(arrayLen(arguments) EQ 2) delim = arguments[2];
for(i = 1 ; i lte listLen(list,delim); i = i + 1 ) {
if (len(listGetAt(list,i,delim)) gt len(item)) item = listGetAt(list,i,delim);
}
return item;
}
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