Re[2]: [PHP] Problem with a while loop

From: Date: Thu, 07 Oct 2004 19:11:53 +0000
Subject: Re[2]: [PHP] Problem with a while loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-198880@lists.php.net to get a copy of this message
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@directphp.com

« previous php.general (#198880) next »