Skip to content

Instantly share code, notes, and snippets.

@iboved
Last active February 3, 2016 11:26
Show Gist options
  • Save iboved/f09ee91951616033f359 to your computer and use it in GitHub Desktop.
Save iboved/f09ee91951616033f359 to your computer and use it in GitHub Desktop.
<?php
public function dayFilter($day)
{
if ($day <= 0) {
return '0 дней';
}
if ($day <= 10 || $day >= 20) {
switch ($day % 10) {
case 1:
return $day . ' день';
break;
case 2:
case 3:
case 4:
return $day . ' дня';
break;
default:
return $day . ' дней';
}
} else {
return $day . ' дней';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment