if you use upper case and lower case use this function to get the right position
function offset(string $char): int {
$abcUpper = range('A', 'Z');
$abcLower = range('a', 'z');
if (ctype_upper($char)) return array_search($char, $abcUpper) + 1;
else return array_search($char, $abcLower) + 1;
}
test
echo offset("a"); // 1
if you use an array and you want to get the position to use in an array
function offset(string $char): int {
$abcUpper = range('A', 'Z');
$abcLower = range('a', 'z');
if (ctype_upper($char)) return array_search($char, $abcUpper);
else return array_search($char, $abcLower);
}
test
echo offset("a"); // 0