RE: [PHP] Adding zeros in front

2002-06-10 Thread César L . Aracena
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 Gene

RE: [PHP] Adding zeros in front

2002-06-10 Thread John Holmes
> Sent: Monday, June 10, 2002 11:20 PM > To: César L. Aracena; PHP General List > Subject: Re: [PHP] Adding zeros in front > > I think certain types of INT fields (not sure which ones) zero fill the > number to the field length... you should read up on the col types, and > maybe &g

Re: [PHP] Adding zeros in front

2002-06-10 Thread Clay Loveless
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: [PH

RE: [PHP] Adding zeros in front

2002-06-10 Thread Martin Towell
$num2 = sprintf("%4d", $num); the "d" might have to be something else, can't remember -Original Message- From: Justin French [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 11, 2002 1:20 PM To: César L. Aracena; PHP General List Subject: Re: [PHP] Adding zeros i

Re: [PHP] Adding zeros in front

2002-06-10 Thread Justin French
I think certain types of INT fields (not sure which ones) zero fill the number to the field length... you should read up on the col types, and maybe change it over. Maybe do a search on "zerofill" / "zero fill". Anyhoo, to solve your immediate problem, you could check the length of $row[main_gro

[PHP] Adding zeros in front

2002-06-10 Thread César L . Aracena
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 w