Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function num2word($num, $words)
- {
- $num = $num % 100;
- if ($num > 19) {
- $num = $num % 10;
- }
- switch ($num) {
- case 1: {
- return ($words[0]);
- }
- case 2:
- case 3:
- case 4: {
- return ($words[1]);
- }
- default: {
- return ($words[2]);
- }
- }
- }
- // example
- $words = array("отзыв", "отзывов", "отзыва");
- $num = 10;
- echo "Осталось ".num2word($num, $words);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement