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', }; }
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Output for 5.4.6
Parse error: syntax error, unexpected ':', expecting '{' in /in/oBEr2 on line 3
Process exited with code 255.

preferences:
59.84 ms | 844 KiB | 4 Q