A 0-Beginning data loop accumulation problem

Source: Internet
Author: User
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.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.