Re: note 25278 added to function.str-repeat
| From: | Jesus M. Castagnetto | Date: | Tue, 17 Sep 2002 23:01:53 +0000 |
| Subject: | Re: note 25278 added to function.str-repeat | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-36868@lists.php.net to get a copy of this message | ||
Fixed your note. Removed the incorrect one.
--- dmarsh.NO.SPAM.PLEASE@spscc.ctc.edu wrote:
> I little typo. doesn't effect the code but can waste
> string space... Please note the removal of
> "strlen($input) *" from the previous to the current
> post: (oops, I don't know what I was on with the
> previous post!!!)..
> Updated (corrected) function:
> <?php
>
> // use this function:
> function str_repeat2($input, $length) {
> // returns the output exactly $length using $input
> to fill that length
> $answer="";
>
> if ($length>=1 && strlen($input)>=1) {
> $answer = substr(str_repeat($input,
> ceil($length/strlen($input)) ), 0, $length);
> }
>
> return $answer;
> }
>
> //demo the function's use:
> $t="-=-";
> print str_repeat2($t,0)."\n";
> print str_repeat2($t,1)."\n";
> print str_repeat2($t,2)."\n";
> print str_repeat2($t,3)."\n";
> print str_repeat2($t,4)."\n";
> print str_repeat2($t,5)."\n";
> print str_repeat2($t,6)."\n";
> ?>
> --
> http://www.php.net/manual/en/function.str-repeat.php
>
http://master.php.net/manage/user-notes.php?action=edit+25278
>
http://master.php.net/manage/user-notes.php?action=delete+25278
>
http://master.php.net/manage/user-notes.php?action=reject+25278
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
=====
--- Jesus M. Castagnetto <jmcastagnetto@php.net>
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com