Created
January 10, 2014 13:38
-
-
Save argnist/8352061 to your computer and use it in GitHub Desktop.
Snippet Units for multiple declinations
This file contains 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 | |
$forms = explode(',', $scriptProperties['forms']); | |
$n = $scriptProperties['count']; | |
if (count($forms) < 3) return; | |
if (($n % 10 == 1) && ($n % 100 != 11)) { | |
$return = $forms[0]; | |
} elseif (($n % 10 >= 2) && ($n %10 <= 4) && ($n % 100 < 10 || $n % 100 >= 20)) { | |
$return = $forms[1]; | |
} else { | |
$return = $forms[2]; | |
} | |
return trim($return); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment