Skip to content

Instantly share code, notes, and snippets.

@samelm
Last active January 12, 2018 11:03
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 samelm/f978f9eeec0e9c368d553772f3a870ea to your computer and use it in GitHub Desktop.
Save samelm/f978f9eeec0e9c368d553772f3a870ea to your computer and use it in GitHub Desktop.
Determination declension words
<?php
function declension($num, $words)
{
$num = $num % 100;
if ($num > 19) {
$num = $num % 10;
}
switch ($num) {
case 1: {
return($words[0]);
}
case 2: case 3: case 4: {
return($words[1]);
}
default: {
return($words[2]);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment