- preg_match: documentation ( source)
- array_key_last: documentation ( source)
<?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";
}