note 30436 deleted from function.str-repeat by nlopess
| From: | nlopess@php.net | Date: | Sun, 20 May 2007 13:45:51 +0000 |
| Subject: | note 30436 deleted from function.str-repeat by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126738@lists.php.net to get a copy of this message | ||
Note Submitter: Gal Chen
----
a response to dmarsh
if u do wanna write a function that fills a string to a length its best to use a recoursive function
function str_repeattolength ($str, $length) {
$strlength= strlen($str);
if ($strlength>= $length) {
return substr($str,0,$length);
} else {
return $str . str_repeattolength($str, $length - $strlength);
}
}
or just use str_pad