note 21226 added to function.str-pad
| From: | jared at dctkc dot com | Date: | Fri, 03 May 2002 20:25:17 +0000 |
| Subject: | note 21226 added to function.str-pad | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30139@lists.php.net to get a copy of this message | ||
matthew.somerville's code did NOT work for me.
neither did bert@catsburg.com's.
neither did any other documentation.
(if I isolated the code by itself, they all worked; but in the context I was using it, $value was
numeric, and there is NO WAY to force it to be a string in PHP).
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 (I use sprintf to left-pad
$value with zeros to a length of 4):
sprintf("%04s",trim($value));
--
http://www.php.net/manual/en/function.str-pad.php
http://master.php.net/manage/user-notes.php?action=edit+21226
http://master.php.net/manage/user-notes.php?action=delete+21226
http://master.php.net/manage/user-notes.php?action=reject+21226