Auto Pluralize
I created a little helper for auto-pluralizing a word using the Inflection class that comes with CakePHP. All I do is pass it the word and the count. The result will be something like, "1 member" or "2 members".
class PluralHelper extends Helper {
//$s = the string
//$c = the count
function ize($s, $c)
{
if($c == 0 || $c > 1)
{
$inflect = new Inflector();
return $c . ' ' . $inflect->pluralize($s);
}else{
return $c . ' ' . $s;
}
}
}
Using the Plural helper is really easy. First, be sure to add it to your controller:
var $helpers = array('Html','Plural');
After that, in your view, call it like this:
echo $plural->ize('member',2)
TIPS, TRICKS & BOOKMARKS
I'm Jonathan Snook and I write about web design and development. I 







Conversation
Great Helper,
I'd suggest using:
if($c != 1) {...}instead of your current condition. That way you properly cover all the decimal cases too such as 0.1 or 1.5, etc.
If you give it some thought: the only time you don't use the plural with a numer before the word is for 1!