Re: pad numbers
| From: | Wang Shengli | Date: | Fri, 10 Oct 2003 15:06:03 +0000 |
| Subject: | Re: pad numbers | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165752@lists.php.net to get a copy of this message | ||
Sorry,
it should be
$dd = sprintf("%02d", $d);
will generate $dd = "05";
If you want 005;
use
$dd =sprintf("%03d", $d);
if you want XXX5;
use
$dd = sprintf("%X4d", $d);
----- Original Message -----
From: "Diana Castillo" <diana@interhotel.com>
To: <php-general@lists.php.net>
Sent: Friday, October 10, 2003 10:44 AM
Subject: [PHP] pad numbers
> is there a function to convert a number that has less than two digits into
a
> number with a leading zero?
> for instance, to convert a "5" to "05" but to leave a "11" as
> "11"
> thanks,
> Diana
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>