note 56054 deleted from function.str-repeat by tomsommer
| From: | tomsommer@php.net | Date: | Fri, 03 Mar 2006 10:41:54 +0000 |
| Subject: | note 56054 deleted from function.str-repeat by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-104762@lists.php.net to get a copy of this message | ||
Note Submitter: Roland Knall<roland dot knall at aerie dot at>
----
You can use this function for a simple leading zero function. I use it the following way:
function lzero ( $nr, $length = 2 ) {
if ( strlen ( trim ( $nr ) ) >= $length
return $nr;
return str_repeat ( "0", $length strlen ( trim ( $nr ) ) ).$nr;
}
The trim is just for extra safety, so that I do not count whitespaces