带数字和字母的代码序列,不带 0,1,o & i

code sequences with number and letter without 0,1,o & i

我需要制作代码序列

例如。从 A5B 开始,下一个代码将是 A5C、A5D... 直到 A59 然后下一个 A6A,A6B...A99 然后下一个 BAA,BAB,BAC

序列是 A-Z 然后连续 2-9

$x = $last; // Get Last Value From DB
$a = substr($x,0,1); // Get First String
$b = substr($x,1,1); // Get Middle String
$c = substr($x, -1); // Get Last String
if($c == 'Z'){
$x = $a.$b.'0';
}
elseif($c == '9'){
if ($b == 'Z'){
$x = $a.'0'.'A';
}
elseif($b == '9'){
$a++;
$x = $a.'A'.'A';
}
else{
$b++;
$x = $a.$b.'A';
}
}
else{
$x++;
}

它的工作原理,但问题是如何在不使用 0,1,o & i 的情况下制作代码序列

请帮忙 对不起我的英语

如果您不担心性能,一个简单的解决方法是只使用一个 do-while 循环来不断迭代,直到 $x 不再包含任何不需要的字符:

$x = $last; // Get Last Value From DB
do {
    $a = substr($x, 0, 1); // Get First String
    $b = substr($x, 1, 1); // Get Middle String
    $c = substr($x, -1); // Get Last String
    if ($c == 'Z') {
        $x = $a.$b.'0';
    } elseif ($c == '9') {
        if ($b == 'Z') {
            $x = $a.'0'.'A';
        } elseif ($b == '9') {
            $a++;
            $x = $a.'A'.'A';
        } else {
            $b++;
            $x = $a.$b.'A';
        }
    } else {
        $x++;
    }
} while (preg_match('/[01OI]/', $x));