note 21227 rejected from function.sprintf by sander
| From: | sander@php.net | Date: | Fri, 03 May 2002 20:30:44 +0000 |
| Subject: | note 21227 rejected from function.sprintf by sander | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-30147@lists.php.net to get a copy of this message | ||
str_pad does not always work, especially when
left-padding a numeric string with zeros.
I had to roll my own. I used 'trim' to _force_
the value of $value to be string, because as
long as PHP thought it was numeric, I could
not use any form of left-padding with zeros.
This worked:
sprintf("%04s",trim($value));