If your application is international and uses the gettext extension, you can do something like this:
sprintf(ngettext('%d minute', '%d minutes', $amount), $amount);
You can create a wrapper function for it:
function pluralize($singular, $plural, $num) {
return sprintf(ngettext($singular, $plural, $num), $num);
}
This is the best imo way.
source
share