自动递增字母数字字符的PHP

问题描述:

是否可以使用php自动增加字母数字,所以它看起来像:

Is is possible to auto increment an alphanumeric number with php so it looks like:

AB001
AB002
...
...
BA001
...
...
ZZ001

然后我需要在varchar(5)中将此代码添加到mysql中.

This code will then need to be added to mysql, I was thinking a varchar(5).

干杯

尝试一下并查看

$x = 'AA998';
for($i = 0; $i < 10; $i++) {
    echo $x++,'<br />';
}

编辑

字母和数字相反

$x = '000AY';
for($i = 0; $i < 10; $i++) {
    echo $x++,'<br />';
}

或在ZZ999之后反转

or reversal after ZZ999

$x = 'ZZ998';
for($i = 0; $i < 10; $i++) {
    $x++;
    if (strlen($x) > 5)
        $x = '000AA';
    echo $x,'<br />';
}