mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
Plural php + ts
This commit is contained in:
9
plural/php/index.php
Normal file
9
plural/php/index.php
Normal 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)]
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user