note 27033 deleted from function.str-repeat by nlopess
| From: | nlopess@php.net | Date: | Sun, 20 May 2007 13:45:42 +0000 |
| Subject: | note 27033 deleted from function.str-repeat by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126737@lists.php.net to get a copy of this message | ||
Note Submitter: bob at bobarmadillo dot com
----
While dmarsh's function is nice it duplicates the function str_pad().
str_repeat is good when you want the entire string repeated.
For instance, if you want to put 6 's in somewhere, str_pad will cut it off at odd
places whereas str_repeat will return 6 full  's.
the following will return the same result as dmarsh's code.
$t = "-=-";
print str_pad('',0,$t)."\n";
print str_pad('',1,$t)."\n";
print str_pad('',2,$t)."\n";
...etc.