Re[2]: Problem with a while loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello djoseph,

Thursday, October 7, 2004, 11:34:22 AM, you wrote:


>> The following script would look like this when run
>> 00001
>> 2
>> 3
>> 4
>> I needed it to look like this
>> 00001
>> 00002
>> 00003

dtrc> You're going to want to use printf or sprintf to format the numbers.

dtrc> example: printf( "%05d", $i ); 

dtrc> this would print out your number, then left fill it will the zeros you want.

dtrc> -Dan Joseph

 This is the actual script I need it to work in.
 I still am not sure how I would use printf or sprintf I don't want
 to pad the numbers I need the loop to leave the number alone.
 The startnumber and stopnumber will always change. some times they
 will start with a whole number and sometimes they will start with
 just one 0. As you can see with this range of number it starts with
 00001 it needs to add 1 to that number to make it 00002 when it gets
 into the 100 it needs to look like this 00100.


$startnumber="00001";
$stopnumber="02200";

while ($i <= $stopnumber):
echo $i;
echo "<div align='center'><strong>$i</strong></div>";
echo "<br>";
flush();
// get a web page into an array and print it out
$fcontents = file ("http://sos.state.nv.us/corp_nme.asp?corpnum=X$year"; . $i . "0");
while (list ($line_num, $line) = each ($fcontents)) {
        if ($line_num==40){
        $f=strip_tags($line);
echo $f;



......other code


++$i;
endwhile;


-- 
Best regards,
 Richard                            mailto:rdkurth@xxxxxxxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux