Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counter question

Status
Not open for further replies.

cleansedbb

Technical User
Feb 11, 2002
95
US
is there a way to add a 0 in front of the counter for single digits.

i.e. 01, 02, 03, 04, 05, 06, 07, 08, 09.
then it'll go 10, 11, 12

what I have been using is

for( $counter = 1; $counter < $DateM; $counter++)
{
dostuff
}

TIA
 
ya.
if($counter <= 9) { print &quot;0$counter&quot;; } else { print &quot;$counter&quot;; }
 
the old classic way:
printf(&quot;%02d\n&quot;,$counter); -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top