Added pluralize function
Takes a word and a variable and determines if the word should be plural. Optionally returns the variable prepended to the output. Happy Fucking New Year!
This commit is contained in:
parent
fe0fd407cf
commit
42fc4704c6
2 changed files with 60 additions and 0 deletions
|
@ -113,6 +113,36 @@ class String
|
|||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ Pluralize
|
||||
|
||||
/**
|
||||
* Pluralize
|
||||
*
|
||||
* Based on a passed integer, the word will be pluralized. A value of zero
|
||||
* will also pluralize the word (e.g. 0 things not 0 thing).
|
||||
*
|
||||
* @static
|
||||
* @param string $string the word to plurailze
|
||||
* @param integer $count the count to interrogate
|
||||
* @param boolean $both (optional) include count in return
|
||||
* @return string pluralized word
|
||||
*/
|
||||
public static function pluralize($string, $count, $both = false)
|
||||
{
|
||||
if ($count != 1)
|
||||
{
|
||||
$string .= 's';
|
||||
}
|
||||
|
||||
if ($both)
|
||||
{
|
||||
$string = $count . ' ' . $string;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ Random
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue