note 21227 added to function.sprintf
| From: | jared at dctkc dot com | Date: | Fri, 03 May 2002 20:27:54 +0000 |
| Subject: | note 21227 added to function.sprintf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30141@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));
--
http://www.php.net/manual/en/function.sprintf.php
http://master.php.net/manage/user-notes.php?action=edit+21227
http://master.php.net/manage/user-notes.php?action=delete+21227
http://master.php.net/manage/user-notes.php?action=reject+21227