note 56054 added to function.str-repeat
| From: | RolandKnall | Date: | Mon, 22 Aug 2005 08:41:29 +0000 |
| Subject: | note 56054 added to function.str-repeat | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94018@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.str-repeat.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56054
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56054&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56054&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56054&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56054&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56054&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56054&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56054&report=yes
Search -- http://master.php.net/manage/user-notes.php