Last active
January 12, 2018 11:03
-
-
Save samelm/f978f9eeec0e9c368d553772f3a870ea to your computer and use it in GitHub Desktop.
Determination declension words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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