Re: Re: Formatting an integer
| From: | BEOI 7308 | Date: | Wed, 23 Apr 2003 07:33:15 +0000 |
| Subject: | Re: Re: Formatting an integer | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144964@lists.php.net to get a copy of this message | ||
>www.php.net/str_pad
woo !
that function does exactly what i want, it's great,
tho i didn't know about it so i wrote one myself, here it is :
function format_id($id,$x) {
//$id = the integer
//$x = number of digits returned
$string = "";
for ($i=0;$i<($x-strlen($id));$i++) $string.= "0";
return $string.$id;
}
Salah Faya a écrit :
> www.php.net/str_pad
>
> ----- Original Message -----
> From: "Torsten Ueberschar" <torsten@ueberschar.de>
> To: <php-general@lists.php.net>
> Sent: Tuesday, April 22, 2003 6:47 PM
> Subject: [PHP] Re: Formatting an integer
>
> > Hi, have you tried to use printf or sprintf ?
> >
> > Torsten
> >
> > "Beoi 7308" <beoi.7308@cpam-tourcoing.cnamts.fr> schrieb im Newsbeitrag
> > news:3EA53EBE.62C92A31@cpam-tourcoing.cnamts.fr...
> > > Hi list,
> > >
> > > I have an integer i would want to print as say 001, 002, ..., 010, etc
> > > ...
> > > Is there a function i can use for that or do i have to count the digits
> > > of
> > > the number and print as many zeroes as i need before the integer ?
> > >
> > > thanks in advance
> > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php