Skip to content

Instantly share code, notes, and snippets.

@im-sad
Created September 28, 2016 11:24
Show Gist options
  • Save im-sad/d1e052312fd0641d8f788fa7ec61ce80 to your computer and use it in GitHub Desktop.
Save im-sad/d1e052312fd0641d8f788fa7ec61ce80 to your computer and use it in GitHub Desktop.
Numeric ends
<?
/* Склонение числительных */
function numEnd($num, $titles) {
$cases = array(2, 0, 1, 1, 1, 2);
return $num . " " . $titles[($num % 100 > 4 && $num % 100 < 20) ? 2 : $cases[min($num % 10, 5)]];
}
numEnd($resultHours, array('час','часа','часов'));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment