[PHP-DEV] Bug #583 Updated: sprintf not allowing zero padding on decimal numbers From: Bug Database (php-dev <email protected>)
Date: 09/10/98

ID: 583
Updated by: zeev
Reported By: stef <email protected>
Status: Closed
Bug Type: Misbehaving function
Assigned To:
Comments:

[jim]
Unfortunately, supporting %.# for decimal numbers isn't
quite trivial -- for example, sprintf("%3.2d", 8) produces
" 08". (Not that this can't or shouldn't be supported,
just making note of the fact that it isn't trivial and
requires handling cases like that.)

[ssb]
PHP's formatter is a bit different from that of libc here.
Everything after the "." in the formatting specifier
applies to the decimal part of a floating-point number,
(or the truncation length for strings). Won't
sprintf("%02d", $foo) do what you want, or have I
misunderstood your problem?

[zeev]
this has been lingering for too long, Stig's solution works perfectly.

Full Bug description available at: http://ca.php.net/bugs.php3?id=583

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>