Skip to content

Instantly share code, notes, and snippets.

@pwnz22
Created September 3, 2016 13:43
Show Gist options
  • Save pwnz22/1dbf8f033ccec1f0b263b0e772dd2de4 to your computer and use it in GitHub Desktop.
Save pwnz22/1dbf8f033ccec1f0b263b0e772dd2de4 to your computer and use it in GitHub Desktop.
better variant
<?php
function human_plural_form($number, $titles = array('комментарий', 'комментария', 'комментариев'))
{
$cases = array(2, 0, 1, 1, 1, 2);
return $number . " " . $titles[($number % 100 > 4 && $number % 100 < 20) ? 2 : $cases[min($number % 10, 5)]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment