Created
June 15, 2016 09:41
-
-
Save dimayakovlev/94ed390298ecca54ba8e73321c8c04ac to your computer and use it in GitHub Desktop.
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
/** | |
* @desc Функция получения русскоязычного варианта окончания для переданного числа | |
* @param float $value Число, для которого надо подобрать окончание | |
* @param array $names Массив имён вида [0]имя одного; [1]имя от 2 до 4; [2]имя 0 и от 5 до 20 | |
* @return string Возвращает соответствующее числу слово | |
* @link https://habrahabr.ru/post/51887/#comment_1375421 | |
*/ | |
function getNumberWord($value,$names){ | |
$temp = strval($value); | |
$temp = $temp[utf8_strlen($temp)-1]; | |
return (($temp>1 and $temp <5 and (intval($value)>19 or intval($value)<10))?$names[1]:($temp==1?$names[0]:$names[2])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment