user3649115 user3649115 - 1 year ago 99
PHP Question

Serial number with alphabetes and numbers

Need PHP alphanumeric count that starts from A001 and goes uptill ZZ999

It starts from A001 and goes on like A002, A003 .....

and after A999 - it changes to B001 and so on till ZZ999

my code is work for only A999 to Z999.

how can this be done ... ?

Can anyone here help me out ..?

thanks in advance !!

foreach (range('A', 'Z') as $letter) {
foreach (range(1, 100) as $number) {
echo $letter.str_pad($number, 3, '0', STR_PAD_LEFT)."\n";

Answer Source

Try like this

for ($letter = 'A'; $letter !== 'AAA'; $letter++){
    foreach (range(1, 999) as $number) {
            echo $letter.str_pad($number, 3, '0', STR_PAD_LEFT)."\n";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download