Today, we are going to build a batch of contract numbers and have problems, such as
start=0066812~end=0066818
for ($start; $start <= $end; $start + +) {}
In addition to 0066812, the back of the full 00 is removed, what method can be reserved for 0??
Reply to discussion (solution)
$start = 66812; $end = 66818;for ($start; $start <= $end; $start + +) { $s = sprintf ('%07d ', $start); Echo $s. '
';}
0066812006681300668140066815006681600668170066818
$start = 66812; $end = 66818;for ($start; $start <= $end; $start + +) { $s = sprintf ('%07d ', $start); Echo $s. '
';}
0066812006681300668140066815006681600668170066818
When assigning a value, be sure to
$start = 0066812;
$end = 0066818;
There are two in front of 0
Because there may be 009999 to 010000, anyway 09 is 10, the front is not two 0
What's the difference?
$start = ' 0066812 '; $end = ' 0066818 '; for ($start; $start <= $end; $start + +) { $s = sprintf ('%07d ', $start); Echo $s. '
';}
0066812
0066813
0066814
0066815
0066816
0066817
0066818
But if the writing $start = 0066812;
That's the octal number, it's all screwed up.
What's the difference?
$start = ' 0066812 '; $end = ' 0066818 '; for ($start; $start <= $end; $start + +) { $s = sprintf ('%07d ', $start); Echo $s. '
';}
0066812
0066813
0066814
0066815
0066816
0066817
0066818
But if the writing $start = 0066812;
That's the octal number, it's all screwed up.
Thank you, it's very good, master.