CFLib.org – Common Function Library Project

pluralize(quantity, singular, plural)

Last updated February 19, 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));
}

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

Created by Raymond Camden / Design by Justin Johnson