Plural php + ts

This commit is contained in:
2022-08-13 23:59:23 +07:00
committed by GitHub
parent e7fc5a37d5
commit b3893a5e3e
4 changed files with 55 additions and 1 deletions
+9
View File
@@ -0,0 +1,9 @@
<?php
function plural(int $count, array $words)
{
$cases = [2, 0, 1, 1, 1, 2];
return $words[
$count % 100 > 4 && $count % 100 < 20 ? 2 : $cases[min($count % 10, 5)]
];
}