Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kovalenko-anton/640673c9baf6987707cd6304269965d0 to your computer and use it in GitHub Desktop.
Save kovalenko-anton/640673c9baf6987707cd6304269965d0 to your computer and use it in GitHub Desktop.
<?php // склонение количества комментариев
function plural_form( $number, $after) {
$cases = array (2, 0, 1, 1, 1, 2);
echo $number.' '.$after[ ($number%100>4 && $number%100<20) ? 2: $cases[min($number%10, 5)] ];
}
?>
<h2><?php plural_form( get_comments_number(), array('комментарий','комментария','комментариев'));?></h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment