Advertisement
vanchelo

Untitled

Feb 5th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1.     /**
  2.      * Declension of word
  3.      *
  4.      * @param int $count
  5.      * @param string|array $forms
  6.      * @return string
  7.      */
  8.     public function decliner($n, $forms){
  9.         if (!is_array($forms)) $forms = explode(';',$forms);
  10.         if ($this->lang === 'ru') {
  11.             return $n%10==1 && $n%100!=11 ? $forms[0] : ($n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20) ? $forms[1] : $forms[2]);
  12.         }
  13.         return ($n == 1) ? $forms[0] : $forms[1];
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement