Created
October 21, 2013 10:35
-
-
Save YuriDan/7081794 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
<? // $int - число, $expressions - массив н.р. $expressions = Array("0"=>"программа", "1"=>"программы", "2"=>"программ"); | |
function sklon($int, $expressions) | |
{ | |
if (count($expressions) < 3) $expressions[2] = $expressions[1]; | |
settype($int, "integer"); | |
$count = $int % 100; | |
if ($count >= 5 && $count <= 20) { | |
$result = $expressions['2']; | |
} else { | |
$count = $count % 10; | |
if ($count == 1) { | |
$result = $expressions['0']; | |
} elseif ($count >= 2 && $count <= 4) { | |
$result = $expressions['1']; | |
} else { | |
$result = $expressions['2']; | |
} | |
} | |
return $result; | |
}?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment