Michael Fowler wrote:
> On Tue, Jun 05, 2001 at 08:05:24AM -0400, Herb Hall wrote:
> > $min = "0" . $min if $min < 10;
> >
> > will pad your minutes with a 0. I have used both methods for various
> > reasons. You probably only need to use one or the other. I would use the
> > printf unless you have some need to have the variables padded with 0's.
>
> printf will happily pad with zeroes for you:
>
> printf("%03d\n", 4);
>
> outputs
>
> 004
>
> I see no real reason to use manual padding unless you're trying to be
> consistent in the code.
And even if you do need your variables to be padded, well, that's why
there's sprintf
$min = sprintf("%03d",$min);
print "$min\n";
outputs:
003