Created
September 29, 2012 15:23
-
-
Save gbasov/3804346 to your computer and use it in GitHub Desktop.
Word form
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
function word_form($value, $one_form, $two_form, $five_form){ | |
$form = null; | |
$han_value = $value%100; | |
$ten_value = $value%10; | |
// x05 - x20, x0, x5 - x9, | |
if( ($han_value >= 5 && $han_value <= 20) || in_array( $ten_value, array(0, 5, 6, 7, 8, 9) ) ){ | |
$form = $five_form; | |
// x2, x3, x4 | |
} else if( in_array( $ten_value, array(2, 3, 4) ) ){ | |
$form = $two_form; | |
// 1 | |
} else { | |
$form = $one_form; | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment