CFLib.org – Common Function Library Project

pluralize(quantity, singular, plural)

Last updated February 18, 2004

author

Tony Felice, Ken Fricklas

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Very simple function to display either the plural or singular form for a numeric that is passed in.

Return Values:
Returns a string.

Example:

<cfoutput>
#pluralize(randrange(1,3),"leaf","leaves")#
</cfoutput>

Parameters:

Name Description Required
quantity Quantity. Yes
singular Singular version of the string. Yes
plural Plural version of the string. Yes

Full UDF Source:

/**
 * Very simple function to display either the plural or singular form for a numeric that is passed in.
 * 
 * @param quantity 	 Quantity. (Required)
 * @param singular 	 Singular version of the string. (Required)
 * @param plural 	 Plural version of the string. (Required)
 * @return Returns a string. 
 * @author Tony Felice, Ken Fricklas (sites@breckcomm.com; ken@breckcomm.com) 
 * @version 1, February 18, 2004 
 */
function pluralize(quantity, singular, plural){
	return IIF(quantity EQ 1, DE(singular), DE(plural));
}
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