Page 1 of 1

fill string with a character.

Posted: Thu Jun 26, 2008 4:47 am
by aetoc
I have a string with a one or two digit number and I want to fill it with zeros. Can someone remind me how I do it.

Example:

12 -> 0012, 3 -> 0003


Thanks in advance,
Aetoc

Re: fill string with a character.

Posted: Thu Jun 26, 2008 4:53 am
by WebbieDave

Code: Select all

str_pad($num, 4, '0', STR_PAD_LEFT);

Re: fill string with a character.

Posted: Thu Jun 26, 2008 4:56 am
by aetoc
Thanks. You save me :D

:crazy: :banghead: :dubious: