<?php
function dateSuffix(int $x): string
{
$s = [0,"st","nd","rd"];
return (in_array($x,[1,2,3,21,22,23,31])) ? $s[$x % 10] : "th";
}
function ordinal_suffix_match(int $value): string
{
return match ($value % 100) {
1, 21, 31, 41, 51, 61, 71, 81, 91 => 'st',
2, 22, 32, 42, 52, 62, 72, 82, 92 => 'nd',
3, 23, 33, 43, 53, 63, 73, 83, 93 => 'rd',
default => 'th',
};
}
- Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
preferences:
42.48 ms | 406 KiB | 5 Q