I have a number like 00001
and I want to keep adding 1
to it till I reach 00044
How can I do this in PHP?
I tried but it takes it as 1 not 00001
So basically what I want is
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
.
.
.
.
1
,2
, and so on. Those are integers, PHP can calculate with integers. Once you are going to print the variable, apply formatting to get the desired00001
. That's a string. PHP can print it, but can't calculate with it. (Yes, this is slightly simplified)sprintf("%05d", $number);
will print your number and zero-pad it to 5 characters. You can use$number
however you want (eg. incrementing) before printing/formatting it that way).