Skip to content

Instantly share code, notes, and snippets.

@argnist
Created January 10, 2014 13:38
Show Gist options
  • Save argnist/8352061 to your computer and use it in GitHub Desktop.
Save argnist/8352061 to your computer and use it in GitHub Desktop.
Snippet Units for multiple declinations
<?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