In reply to what Roland Knall wrote:
It is much simpler to use printf() or sprintf() for leading zeros.
<?php
printf("%05d<br>\n", 1); // Will echo 00001
sprintf("%05d<br>\n", 1); // Will return 00001
?>
![]() | str_repeatDescriptionstring str_repeat ( string input, int multiplier )Returns input_str repeated multiplier times. multiplier has to be greater than or equal to 0. If the multiplier is set to 0, the function will return an empty string. See also for, str_pad(), and substr_count(). ![]()
15-Sep-2005 10:32
In reply to what Roland Knall wrote:
22-Jul-2003 01:45
str_repeat does not repeat symbol with code 0 on some (maybe all?) systems (tested on PHP Version 4.3.2 , FreeBSD 4.8-STABLE i386 ).
abodeman at enoughspamalready dot yahoo dot com
28-May-2003 05:35
Recursive functions are almost always slower than the corresponding iterative function. Therefore, dmarsh's function will be faster than Gail's.
Gal Chen
18-Mar-2003 11:18
a response to dmarsh
bob at bobarmadillo dot com
21-Nov-2002 08:26
While dmarsh's function is nice it duplicates the function str_pad().
dmarsh dot NO dot SPAM dot PLEASE at spscc dot ctc dot edu
18-Sep-2002 07:15
If you need an alternate str_repeat function that outputs an exact length using a particular input string to fill that length (as opposed to repeating the input string), try this little gem:
dakota at dir dot bg
25-Jun-2002 06:06
Note that the first argument is parsed only once, so it's impossible to do things like this:
bryantSPAMw at geocities dot SPAM dot com
25-Oct-2001 07:16
(For the benefit of those searching the website:)
| ![]() | |