[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

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

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 in front I think certain

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: [PHP] Adding zeros in front Hi all, Does anyone remembers how to add zeros

RE: [PHP] Adding zeros in front

2002-06-10 Thread John Holmes
, 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 change it over. Maybe do a search

RE: [PHP] Adding zeros in front

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