3v4l.org

run code in 300+ PHP versions simultaneously
<?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', }; }

preferences:
24.86 ms | 404 KiB | 5 Q