This is a discussion on format interger to this "001" etc within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I would like to format a number as 3 characters. 1 shoulb be echo as 001 and 2 as ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On 2004-03-04, Johnny Geling wrote:
> Hello, > > I would like to format a number as 3 characters. 1 shoulb be echo as 001 > and 2 as 002, 12 as 012 and so on. With vb there is a format function > available. What about php. I haven't found it. Al tips are welcome. > http://www.php.net/manual/en/function.str-pad.php eg. echo str_pad("2", 3, "0", STR_PAD_LEFT); // Displays 002 echo str_pad("12", 3, "0", STR_PAD_LEFT); // Displays 012 -- Mike Peters mike [-AT-] ice2o [-DOT-] com http://www.ice2o.com |
|
|||
|
On Thu, 04 Mar 2004 14:50:33 +0100, Johnny Geling
<johnny_rem*ove_this*_.geling@chello.be> wrote: >Hello, > >I would like to format a number as 3 characters. 1 shoulb be echo as 001 >and 2 as 002, 12 as 012 and so on. With vb there is a format function >available. What about php. I haven't found it. Al tips are welcome. > > >Johnny See: http://www.php.net/manual/en/function.str-pad.php |