Created
January 11, 2018 06:09
-
-
Save nccdr/8b2732d929db7eecd70989120c8b7ed5 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
<?php | |
// $apps = 103; | |
// getNumEnding($apps, ['приложение', 'приложения', 'приложений']); | |
function getNumEnding($number, $endingArray) | |
{ | |
$number = $number % 100; | |
if ($number >= 11 && $number <= 19) { | |
$ending = $endingArray[2]; | |
} else { | |
$i = $number % 10; | |
switch ($i) { | |
case (1): | |
$ending = $endingArray[0]; | |
break; | |
case (2): | |
case (3): | |
case (4): | |
$ending = $endingArray[1]; | |
break; | |
default: | |
$ending = $endingArray[2]; | |
} | |
} | |
return $ending; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment