Folgende Ausgabe
A001
A002
A003
A004
A005
A006
A007
A008
A009
A010
B000
B001
B002
B003
B004
B005
B006
B007
B008
B009
B010
C000
C001
C002
C003
C004
C005
C006
C007
C008
C009
C010
67D000
6007
6008
6009
6010
7000
7001
7002
7003
7004
7005
7006
7007
Bei diesem Script:
A001
A002
A003
A004
A005
A006
A007
A008
A009
A010
B000
B001
B002
B003
B004
B005
B006
B007
B008
B009
B010
C000
C001
C002
C003
C004
C005
C006
C007
C008
C009
C010
67D000
6007
6008
6009
6010
7000
7001
7002
7003
7004
7005
7006
7007
Bei diesem Script:
PHP-Code:
$num = "A000";
$max = "C010";
$step = 10;
$count = 0;
$number_of_customer = 40;
// Going from A000..A010 until Z010
while ($count <= $number_of_customer) {
$ord1 = ord($num{0});
$digs = substr($num, 1);
if($num != $max)
{
if (++$digs > $step) {
$num = chr(++$ord1)."000";
} else {
$num = sprintf(chr($ord1)."%03d", $digs);
$count++;
}
} else {
$ord2 = ord($num{0});
if (++$digs > $step) {
$num = $ord1.chr(++$ord2)."000";
} else {
$num = $ord1.sprintf(chr($ord2)."%03d", $digs);
}
}
echo $num."<br>";
}
Kommentar