Skip to content

Instantly share code, notes, and snippets.

@niksamokhvalov
Last active September 8, 2015 14:43
Show Gist options
  • Save niksamokhvalov/c8de3ef588cd258c5439 to your computer and use it in GitHub Desktop.
Save niksamokhvalov/c8de3ef588cd258c5439 to your computer and use it in GitHub Desktop.
Function for declination numbers
/**
* Declination numbers
*
* @param int $num Number
* @param array $words Array with words
* @example declension(3, ['попугай', 'попугая', 'попугаев'])
*
* @return string
*/
function declension($num, $words)
{
return $words[8 >> (828 >> ((30 >> (!($num % 100 - 10 >> 3) << 3) & 1 << $num % 10) >> 1) & 3) & 3];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment