note 14585 added to function.str-pad.php
| From: | matthew dot somerville at trinity dot oxford dot ac dot uk | Date: | Sun, 05 Aug 2001 10:53:15 +0000 |
| Subject: | note 14585 added to function.str-pad.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16330@lists.php.net to get a copy of this message | ||
I find:
$mystr = substr("0000$mystr",-4)
(where the 0s are padding characters and -4 is the negative of the maxlength to pad to) is even
simpler.
http://www.php.net/manual/en/function.str-pad.php