Skip to content

Instantly share code, notes, and snippets.

@KarelWintersky
Forked from fomigo/gist:2382775
Last active August 15, 2016 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KarelWintersky/b37355e966396f9001eb to your computer and use it in GitHub Desktop.
Save KarelWintersky/b37355e966396f9001eb to your computer and use it in GitHub Desktop.
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment