str_pad worked!!! Thank you all...

César Aracena
IS / MCSE+I
Neuquén, NQN
(0299) 156-356688
(0299) 446-6621

> -----Mensaje original-----
> De: Clay Loveless [mailto:[EMAIL PROTECTED]]
> Enviado el: Martes, 11 de Junio de 2002 12:35 a.m.
> Para: PHP-General
> Asunto: Re: [PHP] Adding zeros in front
> 
> Try this:
> 
> echo str_pad($row[main_group],4,"0",STR_PAD_LEFT)."/".$row[sub_group];
> 
> -Clay
> 
> > From: César L. Aracena <[EMAIL PROTECTED]>
> > Date: Tue, 11 Jun 2002 00:11:30 -0300
> > To: "PHP General List" <[EMAIL PROTECTED]>
> > Subject: [PHP] Adding zeros in front
> >
> > Hi all,
> >
> > Does anyone remembers how to add zeros in front of a result number
given
> > by a query to MySQL and returned as an array, so it always shows a 4
> > digit number? I have:
> >
> > [snip]
> > echo $row[main_group]."/".$row[sub_group];
> > [snip]
> >
> > but throws out:
> >
> > 1/0
> > 2/0
> > 3/0
> >
> > instead of:
> >
> > 0001/0
> > 0002/0
> > 0003/0
> >
> > which it should. Thanks in advance,
> >
> > Cesar Aracena <mailto:[EMAIL PROTECTED]>
> > CE / MCSE+I
> > Neuquen, Argentina
> > +54.299.6356688
> > +54.299.4466621
> >
> >
> >


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to