Jump to content


Photo

Printf() help


  • Please log in to reply
1 reply to this topic

#1 Mateobus

Mateobus
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 23 April 2006 - 05:37 PM

Hey i need some help, I want to convert some numbers so they all have a length of 4, by adding a certain number of preceeding zeros to them. so like 7 would print out as 0007, and 77 would print as 0077.
Anyone know the code for this.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 23 April 2006 - 06:31 PM

$num = 77;

printf ('%04d', $num); // --> 0077

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users