Created
August 26, 2015 19:08
-
-
Save dnikonov/2c4a72bd69c1a126dae7 to your computer and use it in GitHub Desktop.
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
if (!function_exists('BITGetDeclNum')) { | |
/** | |
* Функция возвращает окончание слова, в зависимости от примененного к ней числа | |
* Например: 5 товаров, 1 товар, 3 товара | |
* | |
* @param int $value - число, к которому необходимо применить склонение | |
* @param array $status - массив возможных окончаний | |
* @return mixed | |
*/ | |
function BITGetDeclNum($value = 1, $status = array('','а','ов')) { | |
$array = array(2,0,1,1,1,2); | |
return $status[($value % 100 > 4 && $value % 100 < 20)? 2 : $array[($value % 10 < 5) ? $value % 10 : 5]]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment