3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lookup = ['neither', 'upper', 'lower']; $tests = ['A', 'z', '+', '0', 'ǻ', 'Ͱ', null]; foreach ($tests as $test) { $index = preg_match('~(\p{Lu})|(\p{Ll})~u', $test, $out) ? array_key_last($out) : 0; echo "{$test}: {$lookup[$index]}\n"; }
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
A: upper z: lower +: neither 0: neither ǻ: lower Ͱ: upper Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/ldgHN on line 6 : neither
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
A: upper z: lower +: neither 0: neither ǻ: lower Ͱ: upper : neither
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33
Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/ldgHN:6 Stack trace: #0 {main} thrown in /in/ldgHN on line 6
Process exited with code 255.

preferences:
152.25 ms | 409 KiB | 5 Q