I'm trying to iterate with for loop
through 8 digit numbers starting with 0. For example, the first number is: 00000000
and I would like to display next 5 numbers.
So far I managed to accomplish sth. like that:
<?php
$start = 00000000;
$number = 5;
for ($i = $start; $i < $start + $number; $i++) {
$url = sprintf("http://test.com/id/%08d", $i);
echo $url . "\r\n";
}
?>
Result:
http://test.com/id/00000000
http://test.com/id/00000001
http://test.com/id/00000002
http://test.com/id/00000003
http://test.com/id/00000004
There's everything fine with this example, however, problems start with such an example:
<?php
$start = 00050200;
$number = 5;
for ($i = $start; $i < $start + $number; $i++) {
$url = sprintf("http://test.com/id/%08d", $i);
echo $url . "\r\n";
}
?>
The for loop produces:
http://test.com/id/00020608
http://test.com/id/00020609
http://test.com/id/00020610
http://test.com/id/00020611
http://test.com/id/00020612
while I expect:
http://test.com/id/00050200
http://test.com/id/00050201
http://test.com/id/00050202
http://test.com/id/00050203
http://test.com/id/00050204