[thelist] [PHP] Add a leading zero to a single digit integer

Ken Schaefer Ken at adOpenStatic.com
Wed Nov 24 21:24:04 CST 2004


Instead of testing for the length of the string, couldn't you just
concatenate a 0 to the beginning of each string, then just take the two
right-most characters?

Cheers
Ken

: -----Original Message-----
: From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On
: Behalf Of Tim Burgan
: Subject: [thelist] [PHP] Add a leading zero to a single digit integer
: 
: How can I add a leading zero to an integer IF its length it one digit?
: 
: eg.  8 -> 08
:      9 -> 09
:     10 -> 10
:     11 -> 11
: 
: Is there a PHP function to do this? Or is there a function that I can
: use to return the length of digits in the integer - strlen()?
: 
: I had a quick look in the manual but can't find anything..
: 
: Thanks for your time, and help would be greatly appreciated.
: 
: 
: Tim


More information about the thelist mailing list