To generate the auto numbers like 00001

Hi
all

I have given task to generate the autonumbers in php like 00001 and when it comes to 10 it will become like this 00010

any body can help me out.

Thanks
MD.Samiuddin


for($i = 1; $i < 20; $i++){
    echo str_pad($i, 5, '0', STR_PAD_LEFT) . '<br />';
}

Off Topic:

Opps… Beaten!

Here’s a slightly more standard way of doing it.


<?php
printf('%05d', 5);      #00005
printf('%05d', 50);     #00050
printf('%05d', 505);    #00505
printf('%05d', 5050);   #05050
printf('%05d', 50505);  #50505

thanks for your early response, it help me

Thanks & regards

MD.Samiuddin