faqts : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

20 of 21 people (95%) answered Yes
Recently 7 of 8 people (88%) answered Yes

Entry

Is there any easy way to format an integer to have leading zeros? eg. store 12 as 0012.

Mar 13th, 2000 18:36
Kris Erickson, Patrick Gary, unknown unknown, http://www.php.net/manual/function.sprintf.php3


use sprintf, or printf

e.g.

echo sprintf("%04d",12);