programming:php:skloneniya
Склонение слов после числительных
function ruDocs($number){
static $votes=array(' документов', ' документ', ' документа');
$numberLast=intval(substr(strval($number),-1,1));
$numberPreLast=intval(substr(strval($number),-2,2));
if(($numberLast==0) or ((5<=$numberLast) and ($numberLast<=9)) or((11<=$numberPreLast) and ($numberPreLast<=19))){
$type=0;
}elseif(($numberLast==1) and ($numberPreLast!=11)){
$type=1;
}elseif((2<=$numberLast) and ($numberLast<=4)){
$type=2;
}
return $number.$votes[$type];
}
programming/php/skloneniya.txt · Последнее изменение: 2017/03/27 11:26 — artur
